8
8
use App \Value \Property ;
9
9
use App \Value \Sniff ;
10
10
use App \Value \Url ;
11
- use App \Value \Urls ;
11
+ use App \Value \UrlList ;
12
12
use GlobIterator ;
13
13
use phpDocumentor \Reflection \DocBlock \Tags \Var_ ;
14
14
use phpDocumentor \Reflection \DocBlockFactory ;
@@ -58,26 +58,47 @@ public function parse(string $phpFilePath, SourceLocator $projectSourceLocator):
58
58
$ this ->getCode ($ phpFilePath ),
59
59
$ this ->getDocBlock ($ classInfo ->getDocComment ()),
60
60
$ this ->getProperties ($ classInfo ),
61
- $ this ->getLinks ($ classInfo , $ xmlUrls ),
61
+ $ this ->getUrls ($ classInfo , $ xmlUrls ),
62
62
$ description ,
63
63
$ diffs ,
64
64
$ violations
65
65
);
66
66
}
67
67
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
+
68
89
/**
69
90
* @return Url[]
70
91
*/
71
92
private function getXmlUrls (SimpleXMLElement $ xml ): array
72
93
{
73
- $ links = [];
94
+ $ urls = [];
74
95
foreach ($ xml ->link as $ link ) {
75
- $ links [] = new Url (
96
+ $ urls [] = new Url (
76
97
(string )s ((string )$ link )->trim ()
77
98
);
78
99
}
79
100
80
- return $ links ;
101
+ return $ urls ;
81
102
}
82
103
83
104
private function getDescription (SimpleXMLElement $ xml ): string
@@ -174,10 +195,10 @@ private function getPropertyDescription(Roave\ReflectionProperty $property): str
174
195
/**
175
196
* @param Url[] $xmlUrls
176
197
*/
177
- private function getLinks (ReflectionClass $ classInfo , array $ xmlUrls ): Urls
198
+ private function getUrls (ReflectionClass $ classInfo , array $ xmlUrls ): UrlList
178
199
{
179
200
if ($ classInfo ->getDocComment () === '' ) {
180
- return new Urls ([]);
201
+ return new UrlList ([]);
181
202
}
182
203
183
204
$ links = DocBlockFactory::createInstance ()
@@ -188,27 +209,6 @@ private function getLinks(ReflectionClass $classInfo, array $xmlUrls): Urls
188
209
return new Url ($ url );
189
210
}, $ links );
190
211
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 ));
213
213
}
214
214
}
0 commit comments