Gitonomy\Git\Repository::__construct PHP Method

__construct() public method

Available options are: * working_dir : specify where working copy is located (option --work-tree) * debug : (default: true) enable/disable minimize errors and reduce log level * logger : a logger to use for logging actions (Psr\Log\LoggerInterface) * environment_variables : define environment variables for every ran process
public __construct ( string $dir, array $options = [] )
$dir string path to git repository
$options array array of options values
    public function __construct($dir, $options = array())
    {
        $is_windows = defined('PHP_WINDOWS_VERSION_BUILD');
        $options = array_merge(array('working_dir' => null, 'debug' => true, 'logger' => null, 'environment_variables' => $is_windows ? array('PATH' => getenv('path')) : array(), 'command' => 'git', 'process_timeout' => 3600), $options);
        if (null !== $options['logger'] && !$options['logger'] instanceof LoggerInterface) {
            throw new InvalidArgumentException(sprintf('Argument "logger" passed to Repository should be a Psr\\Log\\LoggerInterface. A %s was provided', is_object($options['logger']) ? get_class($options['logger']) : gettype($options['logger'])));
        }
        $this->logger = $options['logger'];
        $this->initDir($dir, $options['working_dir']);
        $this->objects = array();
        $this->debug = (bool) $options['debug'];
        $this->environmentVariables = $options['environment_variables'];
        $this->processTimeout = $options['process_timeout'];
        $this->command = $options['command'];
        if (true === $this->debug && null !== $this->logger) {
            $this->logger->debug(sprintf('Repository created (git dir: "%s", working dir: "%s")', $this->gitDir, $this->workingDir ?: 'none'));
        }
    }

Usage Example

Beispiel #1
0
 public function __construct($dir, $options = [])
 {
     $options['command'] = $options['git_command'];
     $this->perlCommand = $options['perl_command'];
     $this->wikiDir = $options['wiki_dir'];
     unset($options['git_command'], $options['perl_command'], $options['wiki_dir']);
     parent::__construct($dir, $options);
 }
All Usage Examples Of Gitonomy\Git\Repository::__construct