Exemplo n.º 1
0
 public function __construct(Filepath $repoPath)
 {
     $this->repoPath = $repoPath;
     $configFilePath = Filepath::fromNative(implode(DIRECTORY_SEPARATOR, [$this->repoPath, '.git', 'config']));
     $contents = file_exists($configFilePath) ? parse_ini_file($configFilePath, true) : [];
     if (count($contents) === 0 || !file_exists($configFilePath)) {
         throw new \InvalidArgumentException('The configuration is invalid / missing.');
     }
     /** @todo interpret these settings after adding more VCS types */
     $this->settings = parse_ini_file($configFilePath, true);
 }
 public static function get($native, $type = self::STRING)
 {
     switch ($type) {
         case self::FILEPATH:
             return Filepath::fromNative($native);
             break;
         case self::STRING:
             return StringLiteral::fromNative($native);
             break;
         case self::URL:
             return Url::fromNative($native);
             break;
         default:
             $oReflection = new \ReflectionObject(new self());
             $allowedTypes = array_keys($oReflection->getConstants());
             throw new InvalidNativeArgumentException($type, $allowedTypes);
             break;
     }
 }