deeem/hexlet-psr-linter

View on GitHub
src/Rules/CheckersTemplate.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace PsrLinter\Rules;

abstract class CheckersTemplate implements RulesInterface
{
    protected $errors = [];

    protected function addError(\PhpParser\Node $node, $type, $reason, $where = false)
    {
        $where = $where ? $where : $node->name;
        $this->errors[] = [
            'line'    => $node->getAttribute('startLine'),
            'type'    => $type,
            'fixable' => false,
            'where'   => $where,
            'reason'  => $reason,
        ];
    }

    public function flushErrors()
    {
        $errors = $this->errors;
        $this->errors = [];
        return empty($errors) ? false : $errors;
    }

    abstract public function check(\PhpParser\Node $node);
}