deeem/hexlet-psr-linter

View on GitHub
sniffs/FunctionsNamingForCamelCase.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace PsrLinter\Rules;

class FunctionsNamingForCamelCase extends CheckersTemplate implements RulesInterface
{
    public function check(\PhpParser\Node $node)
    {
        if (($node instanceof \PhpParser\Node\Stmt\Function_) &&
            (!preg_match('/^[a-z]+([A-Z]?[a-z]+)+$/', $node->name))) {
            $this->addError($node, 'error', 'Method names MUST be declared in camelCase.');
        }
    }
}