Conditions | 3 |
Paths | 4 |
Total Lines | 91 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
14 | public function testIsUrl() { |
||
15 | $correctUrls = [ |
||
16 | 'https://example.com', |
||
17 | 'http://example.com', |
||
18 | 'http://foo.com/blah_blah', |
||
19 | 'http://foo.com/blah_blah/', |
||
20 | 'http://foo.com/blah_blah_(wikipedia)', |
||
21 | 'http://foo.com/blah_blah_(wikipedia)_(again)', |
||
22 | 'http://www.example.com/wpstyle/?p=364', |
||
23 | 'https://www.example.com/foo/?bar=baz&inga=42&quux', |
||
24 | 'http://df.ws/123', |
||
25 | 'http://userid:[email protected]:8080', |
||
26 | 'http://userid:[email protected]:8080/', |
||
27 | 'http://[email protected]', |
||
28 | 'http://[email protected]/', |
||
29 | 'http://[email protected]:8080', |
||
30 | 'http://[email protected]:8080/', |
||
31 | 'http://userid:[email protected]', |
||
32 | 'http://userid:[email protected]/', |
||
33 | 'http://142.42.1.1/', |
||
34 | 'http://142.42.1.1:8080/', |
||
35 | 'http://fg.ws/', |
||
36 | 'http://fg.ws', |
||
37 | 'http://foo.com/blah_(wikipedia)#cite-1', |
||
38 | 'http://foo.com/blah_(wikipedia)_blah#cite-1', |
||
39 | 'http://foo.com/unicode_(✪)_in_parens', |
||
40 | 'http://foo.com/(something)?after=parens', |
||
41 | 'http://☺.damowmow.com/', |
||
42 | 'http://code.google.com/events/#&product=browser', |
||
43 | 'http://j.mp', |
||
44 | 'ftp://foo.bar/baz', |
||
45 | 'http://foo.bar/?q=Test%20URL-encoded%20stuff', |
||
46 | 'http://مثال.إختبار', |
||
47 | 'http://例子.测试', |
||
48 | 'http://उदाहरण.परीक्', |
||
49 | "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", |
||
50 | 'http://1337.net', |
||
51 | 'http://a.b-c.de', |
||
52 | 'http://223.255.255.254' |
||
53 | ]; |
||
54 | |||
55 | $incorrectUrls = [ |
||
56 | 'http://', |
||
57 | 'http://.', |
||
58 | 'http://..', |
||
59 | 'http://../', |
||
60 | 'http://?', |
||
61 | 'http://??', |
||
62 | 'http://??/', |
||
63 | 'http://#', |
||
64 | 'http://##', |
||
65 | 'http://##/', |
||
66 | 'http://foo.bar?q=Spaces should be encoded', |
||
67 | '//', |
||
68 | '//a', |
||
69 | '///a', |
||
70 | '///', |
||
71 | 'http:///a', |
||
72 | 'foo.com', |
||
73 | 'rdar://1234', |
||
74 | 'h://test', |
||
75 | 'http:// shouldfail.com', |
||
76 | ':// should fail', |
||
77 | 'http://foo.bar/foo(bar)baz quux', |
||
78 | 'ftps://foo.bar/', |
||
79 | 'http://-error-.invalid/', |
||
80 | 'http://-a.b.co', |
||
81 | 'http://a.b-.co', |
||
82 | 'http://0.0.0.0', |
||
83 | 'http://10.1.1.0', |
||
84 | 'http://10.1.1.255', |
||
85 | 'http://224.1.1.1', |
||
86 | 'http://1.1.1.1.1', |
||
87 | 'http://123.123.123', |
||
88 | 'http://3628126748', |
||
89 | 'http://.www.foo.bar/', |
||
90 | 'http://.www.foo.bar./', |
||
91 | 'http://10.1.1.1', |
||
92 | 'http://10.1.1.254' |
||
93 | ]; |
||
94 | |||
95 | foreach($correctUrls as $url) { |
||
96 | $t = $url; |
||
97 | $this->assertTrue(RestValidatorHelper::is_url($url), "$t should be valid"); |
||
|
|||
98 | } |
||
99 | |||
100 | foreach($incorrectUrls as $url) { |
||
101 | $t = $url; |
||
102 | $this->assertFalse(RestValidatorHelper::is_url($url), "$t should be invalid"); |
||
103 | } |
||
104 | } |
||
105 | |||
210 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.