| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 53 | 
| Code Lines | 31 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
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  | 
            ||
| 116 | protected function buildPaymentGatewayStub(  | 
            ||
| 117 | $successValue,  | 
            ||
| 118 | $transactionReference,  | 
            ||
| 119 | $isRedirect = true  | 
            ||
| 120 |     ) { | 
            ||
| 121 | //--------------------------------------------------------------------------------------------------------------  | 
            ||
| 122 | // request and response  | 
            ||
| 123 | |||
| 124 |         $mockResponse = $this->getMockBuilder('Omnipay\Common\Message\AbstractResponse') | 
            ||
| 125 | ->disableOriginalConstructor()->getMock();  | 
            ||
| 126 | |||
| 127 | $mockResponse->expects($this->any())  | 
            ||
| 128 |             ->method('isSuccessful')->will($this->returnValue($successValue)); | 
            ||
| 129 | |||
| 130 | $mockResponse->expects($this->any())  | 
            ||
| 131 |             ->method('isRedirect')->will($this->returnValue($isRedirect)); | 
            ||
| 132 | |||
| 133 | $mockResponse->expects($this->any())  | 
            ||
| 134 |             ->method('getRedirectResponse')->will($this->returnValue( | 
            ||
| 135 |                 new \Symfony\Component\HttpFoundation\RedirectResponse('http://paymentprovider/test/offsiteform') | 
            ||
| 136 | ));  | 
            ||
| 137 | |||
| 138 | $mockResponse->expects($this->any())  | 
            ||
| 139 |             ->method('getTransactionReference')->will($this->returnValue($transactionReference)); | 
            ||
| 140 | |||
| 141 |         $mockRequest = $this->getMockBuilder('Omnipay\Common\Message\AbstractRequest') | 
            ||
| 142 | ->disableOriginalConstructor()->getMock();  | 
            ||
| 143 | |||
| 144 | $mockRequest->expects($this->any())  | 
            ||
| 145 |             ->method('send')->will($this->returnValue($mockResponse)); | 
            ||
| 146 | |||
| 147 | $mockRequest->expects($this->any())  | 
            ||
| 148 |             ->method('getTransactionReference')->will($this->returnValue($transactionReference)); | 
            ||
| 149 | |||
| 150 | |||
| 151 | //--------------------------------------------------------------------------------------------------------------  | 
            ||
| 152 | // Build the gateway  | 
            ||
| 153 | |||
| 154 |         $stubGateway = $this->getMockBuilder('Omnipay\Common\AbstractGateway') | 
            ||
| 155 |             ->setMethods(array('purchase', 'supportsCompletePurchase', 'getName')) | 
            ||
| 156 | ->getMock();  | 
            ||
| 157 | |||
| 158 | $stubGateway->expects($this->any())  | 
            ||
| 159 |             ->method('purchase') | 
            ||
| 160 | ->will($this->returnValue($mockRequest));  | 
            ||
| 161 | |||
| 162 | |||
| 163 | $stubGateway->expects($this->any())  | 
            ||
| 164 |             ->method('supportsCompletePurchase') | 
            ||
| 165 | ->will($this->returnValue($isRedirect));  | 
            ||
| 166 | |||
| 167 | return $stubGateway;  | 
            ||
| 168 | }  | 
            ||
| 169 | }  | 
            ||
| 170 | 
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: