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

__construct() public method

public __construct ( Filesystem $filesystem, string $srcNamespace = '', string $specNamespacePrefix = 'spec', string $srcPath = 'src', string $specPath = '.', string $psr4Prefix = null )
$filesystem PhpSpec\Util\Filesystem
$srcNamespace string
$specNamespacePrefix string
$srcPath string
$specPath string
$psr4Prefix string
    public function __construct(Filesystem $filesystem, $srcNamespace = '', $specNamespacePrefix = 'spec', $srcPath = 'src', $specPath = '.', $psr4Prefix = null)
    {
        $this->filesystem = $filesystem;
        $sepr = DIRECTORY_SEPARATOR;
        $this->srcPath = rtrim(realpath($srcPath), '/\\') . $sepr;
        $this->specPath = rtrim(realpath($specPath), '/\\') . $sepr;
        $this->srcNamespace = ltrim(trim($srcNamespace, ' \\') . '\\', '\\');
        $this->psr4Prefix = null === $psr4Prefix ? null : ltrim(trim($psr4Prefix, ' \\') . '\\', '\\');
        if (null !== $this->psr4Prefix && substr($this->srcNamespace, 0, strlen($psr4Prefix)) !== $psr4Prefix) {
            throw new InvalidArgumentException('PSR4 prefix doesn\'t match given class namespace.' . PHP_EOL);
        }
        $srcNamespacePath = null === $this->psr4Prefix ? $this->srcNamespace : substr($this->srcNamespace, strlen($this->psr4Prefix));
        $this->specNamespace = $specNamespacePrefix ? trim($specNamespacePrefix, ' \\') . '\\' . $this->srcNamespace : $this->srcNamespace;
        $specNamespacePath = $specNamespacePrefix ? trim($specNamespacePrefix, ' \\') . '\\' . $srcNamespacePath : $srcNamespacePath;
        $this->fullSrcPath = $this->srcPath . str_replace('\\', $sepr, $srcNamespacePath);
        $this->fullSpecPath = $this->specPath . str_replace('\\', $sepr, $specNamespacePath);
        if ($sepr === $this->srcPath) {
            throw new InvalidArgumentException(sprintf('Source code path should be existing filesystem path, but "%s" given.', $srcPath));
        }
        if ($sepr === $this->specPath) {
            throw new InvalidArgumentException(sprintf('Specs code path should be existing filesystem path, but "%s" given.', $specPath));
        }
    }

Usage Example

 public function __construct($srcNamespace = '', $specNamespacePrefix = 'spec', $srcPath = 'src', $specPath = '.', Filesystem $filesystem = null, $psr4Prefix = null, $extension = '.php')
 {
     parent::__construct($srcNamespace, $specNamespacePrefix, $srcPath, $specPath, $filesystem, $psr4Prefix);
     $this->extension = $extension;
 }
All Usage Examples Of PhpSpec\Locator\PSR0\PSR0Locator::__construct