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));
}
}