Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
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 |
||
86 | protected function setUp(): void |
||
87 | { |
||
88 | $this->spider = new Spider('http://php-spider.org/A'); |
||
89 | |||
90 | $this->requestHandler = $this->getMockBuilder('VDB\Spider\RequestHandler\RequestHandlerInterface')->getMock(); |
||
|
|||
91 | |||
92 | $this->hrefA = 'http://php-spider.org/A'; |
||
93 | $this->hrefB = 'http://php-spider.org/B'; |
||
94 | $this->hrefC = 'http://php-spider.org/C'; |
||
95 | $this->hrefD = 'http://php-spider.org/D'; |
||
96 | $this->hrefE = 'http://php-spider.org/E'; |
||
97 | $this->hrefF = 'http://php-spider.org/F'; |
||
98 | $this->hrefG = 'http://php-spider.org/G'; |
||
99 | |||
100 | $this->linkA = new DiscoveredUri(new Uri($this->hrefA)); |
||
101 | $this->linkB = new DiscoveredUri(new Uri($this->hrefB)); |
||
102 | $this->linkC = new DiscoveredUri(new Uri($this->hrefC)); |
||
103 | $this->linkD = new DiscoveredUri(new Uri($this->hrefD)); |
||
104 | $this->linkE = new DiscoveredUri(new Uri($this->hrefE)); |
||
105 | $this->linkF = new DiscoveredUri(new Uri($this->hrefF)); |
||
106 | $this->linkG = new DiscoveredUri(new Uri($this->hrefG)); |
||
107 | |||
108 | $this->linkA->setDepthFound(0); |
||
109 | $this->linkB->setDepthFound(1); |
||
110 | $this->linkC->setDepthFound(1); |
||
111 | $this->linkD->setDepthFound(2); |
||
112 | $this->linkE->setDepthFound(1); |
||
113 | $this->linkF->setDepthFound(2); |
||
114 | $this->linkG->setDepthFound(2); |
||
115 | |||
116 | $htmlA = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceA.html'); |
||
117 | $this->responseA = new Response(200, [], $htmlA); |
||
118 | |||
119 | $htmlB = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceB.html'); |
||
120 | $this->responseB = new Response(200, [], $htmlB); |
||
121 | |||
122 | $htmlC = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceC.html'); |
||
123 | $this->responseC = new Response(200, [], $htmlC); |
||
124 | |||
125 | $htmlD = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceD.html'); |
||
126 | $this->responseD = new Response(200, [], $htmlD); |
||
127 | |||
128 | $htmlE = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceE.html'); |
||
129 | $this->responseE = new Response(200, [], $htmlE); |
||
130 | |||
131 | $htmlF = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceF.html'); |
||
132 | $this->responseF = new Response(200, [], $htmlF); |
||
133 | |||
134 | $htmlG = file_get_contents(__DIR__ . '/Fixtures/SpiderTestHTMLResourceG.html'); |
||
135 | $this->responseG = new Response(200, [], $htmlG); |
||
136 | |||
137 | $this->linkToResponseMap[$this->linkA->toString()] = $this->responseA; |
||
138 | $this->linkToResponseMap[$this->linkB->toString()] = $this->responseB; |
||
139 | $this->linkToResponseMap[$this->linkC->toString()] = $this->responseC; |
||
140 | $this->linkToResponseMap[$this->linkD->toString()] = $this->responseD; |
||
141 | $this->linkToResponseMap[$this->linkE->toString()] = $this->responseE; |
||
142 | $this->linkToResponseMap[$this->linkF->toString()] = $this->responseF; |
||
143 | $this->linkToResponseMap[$this->linkG->toString()] = $this->responseG; |
||
144 | |||
145 | $this->requestHandler |
||
146 | ->expects($this->any()) |
||
147 | ->method('request') |
||
148 | ->will($this->returnCallback(array($this, 'doTestRequest'))); |
||
149 | |||
150 | $this->spider->getDownloader()->setRequestHandler($this->requestHandler); |
||
151 | |||
152 | $this->spider->getDiscovererSet()->set(new XPathExpressionDiscoverer('//a')); |
||
153 | } |
||
154 | |||
333 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..