88use App \Value \Property ;
99use App \Value \Sniff ;
1010use App \Value \Url ;
11- use App \Value \Urls ;
11+ use App \Value \UrlList ;
1212use GlobIterator ;
1313use phpDocumentor \Reflection \DocBlock \Tags \Var_ ;
1414use phpDocumentor \Reflection \DocBlockFactory ;
@@ -58,26 +58,47 @@ public function parse(string $phpFilePath, SourceLocator $projectSourceLocator):
5858 $ this ->getCode ($ phpFilePath ),
5959 $ this ->getDocBlock ($ classInfo ->getDocComment ()),
6060 $ this ->getProperties ($ classInfo ),
61- $ this ->getLinks ($ classInfo , $ xmlUrls ),
61+ $ this ->getUrls ($ classInfo , $ xmlUrls ),
6262 $ description ,
6363 $ diffs ,
6464 $ violations
6565 );
6666 }
6767
68+ private function getSniffClassName (string $ phpFilePath ): string
69+ {
70+ $ parts = $ this ->getSniffFileParts ($ phpFilePath );
71+
72+ return "{$ parts [0 ]}\\Sniffs \\{$ parts [1 ]}\\{$ parts [2 ]}Sniff " ;
73+ }
74+
75+ /**
76+ * @return string[]
77+ */
78+ private function getSniffFileParts (string $ filePath ): array
79+ {
80+ $ part = '([^\/]*) ' ;
81+ preg_match ("/ $ part\/Sniffs\/ $ part\/ {$ part }Sniff\.php/ " , $ filePath , $ matches );
82+ if ($ matches === []) {
83+ throw NotASniffPath::fromPath ($ filePath );
84+ }
85+
86+ return array_slice ($ matches , 1 , 3 );
87+ }
88+
6889 /**
6990 * @return Url[]
7091 */
7192 private function getXmlUrls (SimpleXMLElement $ xml ): array
7293 {
73- $ links = [];
94+ $ urls = [];
7495 foreach ($ xml ->link as $ link ) {
75- $ links [] = new Url (
96+ $ urls [] = new Url (
7697 (string )s ((string )$ link )->trim ()
7798 );
7899 }
79100
80- return $ links ;
101+ return $ urls ;
81102 }
82103
83104 private function getDescription (SimpleXMLElement $ xml ): string
@@ -174,10 +195,10 @@ private function getPropertyDescription(Roave\ReflectionProperty $property): str
174195 /**
175196 * @param Url[] $xmlUrls
176197 */
177- private function getLinks (ReflectionClass $ classInfo , array $ xmlUrls ): Urls
198+ private function getUrls (ReflectionClass $ classInfo , array $ xmlUrls ): UrlList
178199 {
179200 if ($ classInfo ->getDocComment () === '' ) {
180- return new Urls ([]);
201+ return new UrlList ([]);
181202 }
182203
183204 $ links = DocBlockFactory::createInstance ()
@@ -188,27 +209,6 @@ private function getLinks(ReflectionClass $classInfo, array $xmlUrls): Urls
188209 return new Url ($ url );
189210 }, $ links );
190211
191- return new Urls (array_merge ($ urls , $ xmlUrls ));
192- }
193-
194- private function getSniffClassName (string $ phpFilePath ): string
195- {
196- $ parts = $ this ->getSniffFileParts ($ phpFilePath );
197-
198- return "{$ parts [0 ]}\\Sniffs \\{$ parts [1 ]}\\{$ parts [2 ]}Sniff " ;
199- }
200-
201- /**
202- * @return string[]
203- */
204- private function getSniffFileParts (string $ filePath ): array
205- {
206- $ part = '([^\/]*) ' ;
207- preg_match ("/ $ part\/Sniffs\/ $ part\/ {$ part }Sniff\.php/ " , $ filePath , $ matches );
208- if ($ matches === []) {
209- throw NotASniffPath::fromPath ($ filePath );
210- }
211-
212- return array_slice ($ matches , 1 , 3 );
212+ return new UrlList (array_merge ($ urls , $ xmlUrls ));
213213 }
214214}
0 commit comments