| Conditions | 1 |
| Paths | 1 |
| Total Lines | 68 |
| Code Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 16 | public function testRender() |
||
| 17 | { |
||
| 18 | $posX = 1; |
||
| 19 | $posY = 3; |
||
| 20 | $width = 2; |
||
| 21 | $height = 4; |
||
| 22 | $image = m::mock(Image::class); |
||
| 23 | $canvas = m::mock(Image::class) |
||
| 24 | ->shouldReceive('insert') |
||
| 25 | ->with($image, 'top-left', (int) $posX, (int) $posY) |
||
| 26 | ->once() |
||
| 27 | ->getMock(); |
||
| 28 | $imageManager = m::mock(ImageManager::class) |
||
| 29 | ->shouldReceive('canvas') |
||
| 30 | ->with($width, $height, '#fff') |
||
| 31 | ->once() |
||
| 32 | ->andReturn($canvas) |
||
| 33 | ->getMock(); |
||
| 34 | |||
| 35 | $fieldParser = m::mock(FieldParserInterface::class) |
||
|
|
|||
| 36 | ->shouldReceive('isDisplayed') |
||
| 37 | ->andReturn(true) |
||
| 38 | ->once() |
||
| 39 | ->shouldReceive('getPositionX') |
||
| 40 | ->andReturn($posX) |
||
| 41 | ->once() |
||
| 42 | ->shouldReceive('getPositionY') |
||
| 43 | ->andReturn($posY) |
||
| 44 | ->once() |
||
| 45 | ->getMock(); |
||
| 46 | |||
| 47 | $parserDocument = m::mock(ParserDocument::class) |
||
| 48 | ->shouldReceive('getFieldParsers') |
||
| 49 | ->andReturn([$fieldParser]) |
||
| 50 | ->once() |
||
| 51 | ->shouldReceive('getWidth') |
||
| 52 | ->andReturn($width) |
||
| 53 | ->once() |
||
| 54 | ->shouldReceive('getHeight') |
||
| 55 | ->andReturn($height) |
||
| 56 | ->once() |
||
| 57 | ->getMock(); |
||
| 58 | |||
| 59 | $fontResolver = function () {}; // @codingStandardsIgnoreLine |
||
| 60 | $graphicResolver = function () {}; // @codingStandardsIgnoreLine |
||
| 61 | $fieldRenderer = m::mock(FieldRendererInterface::class) |
||
| 62 | ->shouldReceive('render') |
||
| 63 | ->with($imageManager, $fieldParser, $fontResolver, $graphicResolver) |
||
| 64 | ->andReturn($image) |
||
| 65 | ->once() |
||
| 66 | ->getMock(); |
||
| 67 | |||
| 68 | $fieldRendererFactory = m::mock(FieldRendererFactory::class) |
||
| 69 | ->shouldReceive('getFieldRenderer') |
||
| 70 | ->with($fieldParser) |
||
| 71 | ->andReturn($fieldRenderer) |
||
| 72 | ->once() |
||
| 73 | ->getMock(); |
||
| 74 | |||
| 75 | $rendererDocument = new RendererDocument( |
||
| 76 | $fieldRendererFactory, |
||
| 77 | $imageManager |
||
| 78 | ); |
||
| 79 | |||
| 80 | $imageActual = $rendererDocument->render($parserDocument, $fontResolver, $graphicResolver); |
||
| 81 | |||
| 82 | $this->assertSame($canvas, $imageActual); |
||
| 83 | } |
||
| 84 | } |
||
| 85 |
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.