PhpSpec\Locator\PSR0\PSR0Locator::findSpecClassname PHP Method

findSpecClassname() private method

private findSpecClassname ( $path ) : null | string
$path
return null | string
    private function findSpecClassname($path)
    {
        // Find namespace and class name
        $namespace = '';
        $content = $this->filesystem->getFileContents($path);
        $tokens = token_get_all($content);
        $count = count($tokens);
        for ($i = 0; $i < $count; $i++) {
            if ($tokens[$i][0] === T_NAMESPACE) {
                for ($j = $i + 1; $j < $count; $j++) {
                    if ($tokens[$j][0] === T_STRING) {
                        $namespace .= $tokens[$j][1] . '\\';
                    } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
                        break;
                    }
                }
            }
            if ($tokens[$i][0] === T_CLASS) {
                for ($j = $i + 1; $j < $count; $j++) {
                    if ($tokens[$j] === '{') {
                        return $namespace . $tokens[$i + 2][1];
                    }
                }
            }
        }
        // No class found
        return null;
    }