Remove releasenotes from build.xml
[phorkie.git] / src / phorkie / ForkRemote.php
1 <?php
2 namespace phorkie;
3
4 class ForkRemote
5 {
6     /**
7      * Contains error message when parse() failed
8      */
9     public $error;
10
11     protected $url;
12
13     /**
14      * Array with keys (URL title) and values (arrays of urls)
15      * Only supported URLs are included.
16      *
17      * @var array
18      */
19     protected $arGitUrls;
20
21
22
23     public function __construct($url)
24     {
25         $this->url = trim($url);
26     }
27
28     public function parse()
29     {
30         $hp = new HtmlParser();
31         $ret = $hp->extractGitUrls($this->url);
32         $this->arGitUrls = $hp->getGitUrls();
33         $this->error = $hp->error;
34
35         return $ret;
36     }
37
38     /**
39      * Iterate through all git urls and return one if there is only
40      * one supported one.
41      *
42      * @return mixed Boolean false or array with keys "url" and "title"
43      */
44     public function getUniqueGitUrl()
45     {
46         $nFound = 0;
47         foreach ($this->arGitUrls as $title => $arUrls) {
48             foreach ($arUrls as $url) {
49                 $nFound++;
50                 $uniqueUrl = array('url' => $url, 'title' => $title);
51             }
52         }
53
54         if ($nFound == 1) {
55             return $uniqueUrl;
56         }
57         return false;
58     }
59
60     public function getGitUrls()
61     {
62         return $this->arGitUrls;
63     }
64
65     /**
66      * Get the URL from which the git URL was derived, often
67      * the HTTP URL.
68      *
69      * @return string
70      */
71     public function getUrl()
72     {
73         return $this->url;
74     }
75
76     public function setUrl($url)
77     {
78         $this->url = $url;
79     }
80 }
81 ?>