| Conditions | 4 |
| Paths | 8 |
| Total Lines | 55 |
| Code Lines | 44 |
| 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 |
||
| 24 | public function testConnect($prompt = null, $promptError = null, $lineEnding = null) |
||
| 25 | { |
||
| 26 | $dsn = 'localhost:80'; |
||
| 27 | $socket = m::mock(Socket::class); |
||
| 28 | $socketFactory = m::mock(SocketFactory::class) |
||
| 29 | ->shouldReceive('createClient') |
||
| 30 | ->with($dsn) |
||
| 31 | ->andReturn($socket) |
||
| 32 | ->once() |
||
| 33 | ->getMock(); |
||
| 34 | |||
| 35 | $telnetClient = m::mock( |
||
| 36 | TelnetClient::class, |
||
| 37 | [$socketFactory, m::mock(PromptMatcher::class), m::mock(InterpretAsCommand::class)] |
||
| 38 | ) |
||
| 39 | ->shouldReceive('setSocket') |
||
| 40 | ->with($socket) |
||
| 41 | ->once(); |
||
| 42 | |||
| 43 | if ($prompt !== null) { |
||
| 44 | $telnetClient |
||
| 45 | ->shouldReceive('setPrompt') |
||
| 46 | ->with($prompt) |
||
| 47 | ->once(); |
||
| 48 | } else { |
||
| 49 | $telnetClient |
||
| 50 | ->shouldReceive('setPrompt') |
||
| 51 | ->never(); |
||
| 52 | } |
||
| 53 | |||
| 54 | if ($promptError !== null) { |
||
| 55 | $telnetClient |
||
| 56 | ->shouldReceive('setPromptError') |
||
| 57 | ->with($promptError) |
||
| 58 | ->once(); |
||
| 59 | } else { |
||
| 60 | $telnetClient |
||
| 61 | ->shouldReceive('setPromptError') |
||
| 62 | ->never(); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ($lineEnding !== null) { |
||
| 66 | $telnetClient |
||
| 67 | ->shouldReceive('setLineEnding') |
||
| 68 | ->with($lineEnding) |
||
| 69 | ->once(); |
||
| 70 | } else { |
||
| 71 | $telnetClient |
||
| 72 | ->shouldReceive('setLineEnding') |
||
| 73 | ->never(); |
||
| 74 | } |
||
| 75 | |||
| 76 | $telnetClient = $telnetClient->getMock()->makePartial(); |
||
| 77 | $telnetClient->connect($dsn, $prompt, $promptError, $lineEnding); |
||
| 78 | } |
||
| 79 | |||
| 173 |
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.