/** * Will iterate the tokens looking for a T_CLASS which should be * in CamelCase and match the file name * * @param Testable $testable The testable object * @return void */ public function apply($testable, array $config = array()) { $tokens = $testable->tokens(); $pathinfo = pathinfo($testable->config('path')); if ($pathinfo['extension'] !== 'php') { return; } $filtered = $testable->findAll(array(T_CLASS)); foreach ($filtered as $key) { $token = $tokens[$key]; $className = $tokens[$key + 2]['content']; if ($className !== Inflector::camelize($className)) { $this->addViolation(array('message' => 'Class name is not in CamelCase style', 'line' => $token['line'])); } elseif ($className !== $pathinfo['filename']) { $this->addViolation(array('message' => 'Class name and file name should match', 'line' => $token['line'])); } } }