| Conditions | 2 |
| Paths | 2 |
| Total Lines | 53 |
| Code Lines | 36 |
| 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 |
||
| 34 | public function setUp() |
||
| 35 | { |
||
| 36 | parent::setUp(); |
||
| 37 | |||
| 38 | // Check dependencies |
||
| 39 | if (!class_exists(Phockito::class)) { |
||
| 40 | $this->skipTest = true; |
||
| 41 | return $this->markTestSkipped("These tests need the Phockito module installed to run"); |
||
| 42 | } |
||
| 43 | |||
| 44 | // Mock link checker |
||
| 45 | $checker = Phockito::mock(LinkChecker::class); |
||
| 46 | Phockito::when($checker) |
||
| 47 | ->checkLink('http://www.working.com') |
||
| 48 | ->return(200); |
||
| 49 | |||
| 50 | Phockito::when($checker) |
||
| 51 | ->checkLink('http://www.broken.com/url/thing') // 404 on working site |
||
| 52 | ->return(404); |
||
| 53 | |||
| 54 | Phockito::when($checker) |
||
| 55 | ->checkLink('http://www.broken.com') // 403 on working site |
||
| 56 | ->return(403); |
||
| 57 | |||
| 58 | Phockito::when($checker) |
||
| 59 | ->checkLink('http://www.nodomain.com') // no ping |
||
| 60 | ->return(0); |
||
| 61 | |||
| 62 | Phockito::when($checker) |
||
| 63 | ->checkLink('/internal/link') |
||
| 64 | ->return(null); |
||
| 65 | |||
| 66 | Phockito::when($checker) |
||
| 67 | ->checkLink('[sitetree_link,id=9999]') |
||
| 68 | ->return(null); |
||
| 69 | |||
| 70 | Phockito::when($checker) |
||
| 71 | ->checkLink('home') |
||
| 72 | ->return(null); |
||
| 73 | |||
| 74 | Phockito::when($checker) |
||
| 75 | ->checkLink('broken-internal') |
||
| 76 | ->return(null); |
||
| 77 | |||
| 78 | Phockito::when($checker) |
||
| 79 | ->checkLink('[sitetree_link,id=1]') |
||
| 80 | ->return(null); |
||
| 81 | |||
| 82 | Phockito::when($checker) |
||
| 83 | ->checkLink(Hamcrest_Matchers::anything()) // anything else is 404 |
||
| 84 | ->return(404); |
||
| 85 | |||
| 86 | Injector::inst()->registerService($checker, LinkChecker::class); |
||
| 87 | } |
||
| 166 |
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.