1 | <?php |
||
45 | class PathInformation implements PathInformationInterface |
||
46 | { |
||
47 | /** |
||
48 | * The repository |
||
49 | * |
||
50 | * @var RepositoryInterface |
||
51 | */ |
||
52 | protected $repository; |
||
53 | |||
54 | /** |
||
55 | * The URL |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $url; |
||
60 | |||
61 | /** |
||
62 | * The absolute path to the resource |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $fullPath; |
||
67 | |||
68 | /** |
||
69 | * The version ref |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $ref; |
||
74 | |||
75 | /** |
||
76 | * Additional arguments |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $arguments; |
||
81 | |||
82 | /** |
||
83 | * The relative path to the resource based on the repository path |
||
84 | * |
||
85 | * Lazy instantiated |
||
86 | * |
||
87 | * @var string |
||
88 | */ |
||
89 | protected $localPath; |
||
90 | |||
91 | /** |
||
92 | * Creates a new path information instance from a given URL |
||
93 | * |
||
94 | * @param RepositoryInterface $repository The repository instance |
||
95 | * @param string $url The URL |
||
96 | * @param string $fullPath The absolute path to the resource |
||
97 | * @param string $ref The version ref |
||
98 | * @param array $arguments The additional arguments given |
||
99 | */ |
||
100 | 114 | public function __construct(RepositoryInterface $repository, $url, $fullPath, $ref, array $arguments) |
|
108 | |||
109 | /** |
||
110 | * Returns the URL |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getUrl() |
||
118 | |||
119 | /** |
||
120 | * Returns the repository instance |
||
121 | * |
||
122 | * @return RepositoryInterface |
||
123 | */ |
||
124 | 86 | public function getRepository() |
|
128 | |||
129 | /** |
||
130 | * Returns the absolute repository path |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 4 | public function getRepositoryPath() |
|
138 | |||
139 | /** |
||
140 | * Returns the absolute path to the resource |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | 98 | public function getFullPath() |
|
148 | |||
149 | /** |
||
150 | * Returns the relative path to the resource based on the repository path |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 46 | public function getLocalPath() |
|
155 | { |
||
156 | 46 | if (!$this->localPath) { |
|
157 | 46 | $this->localPath = $this->repository->resolveLocalPath($this->fullPath); |
|
158 | } |
||
159 | 46 | return $this->localPath; |
|
160 | } |
||
161 | |||
162 | /** |
||
163 | * Returns the version ref |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | 110 | public function getRef() |
|
171 | |||
172 | /** |
||
173 | * Returns the additional arguments given |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | public function getArguments() |
||
181 | |||
182 | /** |
||
183 | * Checks if the given argument exists |
||
184 | * |
||
185 | * @param string $argument The argument name |
||
186 | * @return boolean |
||
187 | */ |
||
188 | 52 | public function hasArgument($argument) |
|
192 | |||
193 | /** |
||
194 | * Returns the given argument from the argument collection |
||
195 | * |
||
196 | * @param string $argument The argument name |
||
197 | * @return string|null The argument value or NULL if the argument does not exist |
||
198 | */ |
||
199 | 4 | public function getArgument($argument) |
|
203 | } |
||
204 |