Create procedure loader instance.

@access public
@param  string                                      $directory
@return \JonnyW\PhantomJs\Procedure\ProcedureLoader
494703
public function createProcedureLoader($directory)
    {
        $procedureFactory = $this->procedureFactory;
        $fileLocator      = $this->createFileLocator($directory);

        $procedureLoader = new ProcedureLoader(
            $procedureFactory,
            $fileLocator
        );

        return $procedureLoader;
    }
1100700
public static function fromDirectory(string $directory): array
    {
        if (!\is_dir($directory)) {
            throw Exception\DirectoryDoesNotExist::fromDirectory($directory);
        }

        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(
            $directory,
            \RecursiveDirectoryIterator::FOLLOW_SYMLINKS
        ));

        $constructs = [];

        foreach ($iterator as $fileInfo) {
            /** @var \SplFileInfo $fileInfo */
            if (!$fileInfo->isFile()) {
                continue;
            }

            if ($fileInfo->getBasename('.php') === $fileInfo->getBasename()) {
                continue;
            }

            $fileName = $fileInfo->getRealPath();

            /** @var string $source */
            $source = \file_get_contents($fileName);

            try {
                $constructsFromFile = self::fromSource($source);
            } catch (Exception\ParseError $exception) {
                throw Exception\ParseError::fromFileNameAndParseError(
                    $fileName,
                    $exception
                );
            }

            if (0 === \count($constructsFromFile)) {
                continue;
            }

            foreach ($constructsFromFile as $construct) {
                $name = $construct->name();

                if (\array_key_exists($name, $constructs)) {
                    $construct = $constructs[$name];
                }

                $constructs[$name] = $construct->definedIn($fileName);
            }
        }

        \usort($constructs, static function (Construct $a, Construct $b) {
            return \strcmp(
                $a->name(),
                $b->name()
            );
        });

        $constructsWithMultipleDefinitions = \array_filter($constructs, static function (Construct $construct) {
            return 1 < \count($construct->fileNames());
        });

        if (0 < \count($constructsWithMultipleDefinitions)) {
            throw Exception\MultipleDefinitionsFound::fromConstructs($constructsWithMultipleDefinitions);
        }

        return \array_values($constructs);
    }
843758
public function moveToDirectory($directory)
    {
        $targetPath = rtrim($directory, '/') . '/' . $this->getClientFilename();

        return $this->moveTo($targetPath);
    }
675345
protected function makeDir($directory)
    {
        if (!$this->filesystem->isDirectory($directory)) {
            $this->filesystem->makeDirectory($directory, 0777, true);
        }
    }
1261626
protected function makeDir($directory)
	{
		if ( ! $this->files->isDirectory($this->getPath($directory)))
		{
			$this->files->makeDirectory($this->getPath($directory), 0777, true);
		}
	}
590969
public function getDir($directory)
    {
        $directory = str_replace('/', DS, $directory);
        if (strpos($directory, $this->getBaseDir()) === false || !file_exists($directory)) {
            $directory = $this->getBaseDir() . DS . ltrim($directory, DS);
        }
        return $directory;
    }
523218
protected function createDir($dir)
    {
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            throw new \RuntimeException(
                sprintf('Unable to create cache directory %s, check permissions', $dir)
            );
        }

        if (!is_writable($dir)) {
            throw new BadPermissionException(
                sprintf('Cache directory %s is not writable, check permissions', $dir)
            );
        }
    }
1175420
protected function createDirectory($directory)
    {
        $isCreated = file_exists($directory) || is_dir($directory) || mkdir($directory, 0777, true);
        
        if (!$isCreated)
            throw new RuntimeException('Cannot create directory ":dir" for generated classed', ['dir' => $directory]);
        
        return $this;
    }
19978
public function loadPackage($directory)
    {
        if (!$this->files->exists($directory)) {
            throw new InvalidPathException("The directory {$directory} does not exist.");
        }

        if (!$this->files->exists($directory . '/composer.json')) {
            throw new InvalidPathException("There is no composer.json file in {$directory}");
        }

        if (!$this->files->exists($directory . '/_newup')) {
            throw new InvalidPathException("There is no _newup directory in {$directory}");
        }

        if (!$this->files->exists($directory . '/_newup/Package.php')) {
            throw new InvalidPathException("A Package.php file must be present in in \"_newup\" directory.");
        }

        $package = Package::fromFile($directory . '/composer.json',
            user_config('configuration.strictComposerValues', true));
        $namespace = package_vendor_namespace($package->getVendor(), $package->getPackage(), true);

        add_psr4($namespace, $directory . '/_newup');


        if (!class_exists($namespace . 'Package', true)) {
            throw new NewUpException("A valid reachable class named 'Package' must be defined.");
        }

        if (!is_subclass_of($namespace . 'Package', BasePackageTemplate::class)) {
            throw new NewUpException("The 'Package' class must extend ".BasePackageTemplate::class);
        }

        return $namespace . 'Package';
    }
504963
protected function _makeDirectory( $directory )
    {
        try
        {
            if ( !is_dir( $directory ) && !is_file( $directory ) && !is_link( $directory ) )
            {
                mkdir( $directory, 0755, true );
            }
        }
        catch ( \Exception $e )
        {
            $this->error( $e->getMessage() );
            die;
        }
    }
1132384
protected function prepareDefaultDirectory() : Directory {
        $path = $this->finder->setWorkingDirectory('/');

        return new Directory($this->factory, $this->finder, $path);
    }
134866
public function cacheDirectory($directory)
    {
        $success = 0;
        $errors = 0;
        $errorDetails = [];

        $renderer = $this->getRenderer();
        $events = $renderer->getCompiler()->getEventListeners();

        foreach ($renderer->scanDirectory($directory) as $inputFile) {
            $renderer->initCompiler();
            $compiler = $renderer->getCompiler();
            $compiler->mergeEventListeners($events);
            $path = $inputFile;
            $this->isCacheUpToDate($path);
            $sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
                $this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
                $success++;
            });
            $error = $sandBox->getThrowable();

            if ($error) {
                $errors++;
                $errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
            }
        }

        return [$success, $errors, $errorDetails];
    }
875135
public function createCommandHydrator(string $directory, bool $recursive) : CommandHydratorInterface
    {
        return new CommandHydrator(
            $this->createCommandFinder(
                $directory,
                $recursive
            )
        );
    }
395922
protected function runDir($directory)
    {
        if (is_array($directory)) {
            return $this->recurseArg($directory, array($this, "runDir"));
        } else {
            $curdir = getcwd();
            chdir($this->phpci->buildPath);

            $phpunit = $this->phpci->findBinary('phpunit');

            $cmd = $phpunit . ' --tap %s "%s"';
            $success = $this->phpci->executeCommand($cmd, $this->args, $this->phpci->buildPath . $directory);
            chdir($curdir);
            return $success;
        }
    }
635484
public function setDirectory($directory)
	{
		$this->directory = $directory;

		// Set the finder to use this directory as well
		$this->finder->in($directory);

		return $this;
	}
223186
public function useFileDriver(string $dir): self
    {
        $this->setDriver(new \BearFramework\App\FileDataDriver($dir));
        return $this;
    }
147424
protected function getRecursiveDirectoryIterator($dir)
    {
        return new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO),
                \RecursiveIteratorIterator::SELF_FIRST,
                \RecursiveIteratorIterator::CATCH_GET_CHILD
                );
    }