1 | <?php |
||
16 | abstract class GitBasedUrlGenerator implements UrlGenerator |
||
17 | { |
||
18 | const REGEX_USER = '(?P<user>[^/]+)'; |
||
19 | const REGEX_REPOSITORY = '(?P<repository>[^/]+)'; |
||
20 | |||
21 | /** |
||
22 | * Returns the domain of the service, like "example.org". |
||
23 | * |
||
24 | * @return string |
||
25 | */ |
||
26 | abstract protected function getDomain(); |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 56 | public function supports($sourceUrl) |
|
35 | |||
36 | /** |
||
37 | * Generates the canonical http url for a repository. |
||
38 | * |
||
39 | * It ensures there is no .git part in http url. It also supports ssh urls |
||
40 | * by converting them in their http equivalent format. |
||
41 | * |
||
42 | * @param string $sourceUrl |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 46 | protected function generateBaseUrl($sourceUrl) |
|
62 | |||
63 | /** |
||
64 | * Get the version to use for the compare url. |
||
65 | * |
||
66 | * For dev versions, it returns the commit short hash in full pretty version. |
||
67 | * |
||
68 | * @param Version $version |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 32 | protected function getCompareVersion(Version $version) |
|
83 | |||
84 | /** |
||
85 | * Extracts information like user and repository from the http url. |
||
86 | * |
||
87 | * @param string $sourceUrl |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | 8 | protected function extractRepositoryInformation($sourceUrl) |
|
108 | |||
109 | /** |
||
110 | * Returns whether an url uses a ssh git protocol. |
||
111 | * |
||
112 | * @param string $url |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 46 | private function isSshUrl($url) |
|
120 | |||
121 | /** |
||
122 | * Transform an ssh git url into an http one. |
||
123 | * |
||
124 | * @param string $url |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | 10 | private function transformSshUrlIntoHttp($url) |
|
143 | } |
||
144 |