| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Copyright (C) 2017 by TEQneers GmbH & Co. KG | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * in the Software without restriction, including without limitation the rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * furnished to do so, subject to the following conditions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * The above copyright notice and this permission notice shall be included in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * all copies or substantial portions of the Software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * THE SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * Git Stream Wrapper for PHP | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @package    TQ_VCS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @subpackage VCS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @subpackage StreamWrapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @copyright  Copyright (C) 2018 by TEQneers GmbH & Co. KG | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | namespace TQ\Vcs\StreamWrapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use TQ\Vcs\Repository\RepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * Represents a given stream wrapper path | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @author     Stefan Gehrig <gehrigteqneers.de> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * @category   TQ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * @package    TQ_VCS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * @subpackage VCS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @copyright  Copyright (C) 2018 by TEQneers GmbH & Co. KG | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 44 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 114 |  |         $this->repository   = $repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 114 |  |         $this->url          = (string)$url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 114 |  |         $this->fullPath     = (string)$fullPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 114 |  |         $this->ref          = (string)$ref; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 114 |  |         $this->arguments    = $arguments; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 107 | 114 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |      * Returns the URL | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      * @return  string | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     public function getUrl() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $this->url; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |      * Returns the repository instance | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      * @return  RepositoryInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 86 |  |     public function getRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 86 |  |         return $this->repository; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |      * Returns the absolute repository path | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |      * @return  string | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 4 |  |     public function getRepositoryPath() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 4 |  |         return $this->getRepository()->getRepositoryPath(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |      * Returns the absolute path to the resource | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |      * @return  string | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 98 |  |     public function getFullPath() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 98 |  |         return $this->fullPath; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 | 110 |  |         return $this->ref; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |      * Returns the additional arguments given | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |      * @return  array | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     public function getArguments() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         return $this->arguments; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 180 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 52 |  |         return array_key_exists($argument, $this->arguments); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 191 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 4 |  |         return ($this->hasArgument($argument)) ? $this->arguments[$argument] : null; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 202 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 203 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 204 |  |  |  |