3815856a8444d62449e72828adfc3d53fd04fe3f
[phorkie.git] / src / phorkie / Repository / ConnectionInfo.php
1 <?php
2 namespace phorkie;
3
4 class Repository_ConnectionInfo
5 {
6     protected $arConfig;
7     protected $repo;
8
9
10     public function __construct(Repository $repo)
11     {
12         $this->repo = $repo;
13         $this->arConfig = parse_ini_file($this->repo->gitDir . '/config', true);
14     }
15
16     public function isFork()
17     {
18         return $this->getOrigin() !== null;
19     }
20
21
22     public function getOrigin()
23     {
24         return $this->getRemote('origin');
25     }
26
27     /**
28      * @return Repository_Remote|null NULL if the remote does not exist, array
29      *                                with repository information otherwise
30      */
31     public function getRemote($name)
32     {
33         if (!isset($this->arConfig['remote ' . $name])) {
34             return null;
35         }
36         return new Repository_Remote($name, $this->arConfig['remote ' . $name]);
37     }
38
39 }
40
41
42 ?>