| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| 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 |
||
| 82 | public function testGetHtml() { |
||
| 83 | |||
| 84 | $bibliographicFilteredRecord = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) |
||
| 85 | ->disableOriginalConstructor() |
||
| 86 | ->getMock(); |
||
| 87 | |||
| 88 | $responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) |
||
| 89 | ->disableOriginalConstructor() |
||
| 90 | ->getMockForAbstractClass(); |
||
| 91 | |||
| 92 | $responseParser->expects( $this->once() ) |
||
| 93 | ->method( 'doFilterResponseFor' ) |
||
| 94 | ->with( $this->identicalTo( 42 ) ); |
||
| 95 | |||
| 96 | $responseParser->expects( $this->any() ) |
||
| 97 | ->method( 'getMessages' ) |
||
| 98 | ->will( $this->returnValue( [] ) ); |
||
| 99 | |||
| 100 | $responseParser->expects( $this->atLeastOnce() ) |
||
| 101 | ->method( 'getFilteredRecord' ) |
||
| 102 | ->will( $this->returnValue( $bibliographicFilteredRecord ) ); |
||
| 103 | |||
| 104 | $message = $this->getMockBuilder( '\Message' ) |
||
| 105 | ->disableOriginalConstructor() |
||
| 106 | ->getMock(); |
||
| 107 | |||
| 108 | $messageBuilder = $this->getMockBuilder( '\SMW\MediaWiki\MessageBuilder' ) |
||
| 109 | ->disableOriginalConstructor() |
||
| 110 | ->getMock(); |
||
| 111 | |||
| 112 | $messageBuilder->expects( $this->any() ) |
||
| 113 | ->method( 'getMessage' ) |
||
| 114 | ->will( $this->returnValue( $message ) ); |
||
| 115 | |||
| 116 | $htmlFormRenderer = $this->getMockBuilder( '\SMW\MediaWiki\Renderer\HtmlFormRenderer' ) |
||
| 117 | ->disableOriginalConstructor() |
||
| 118 | ->setMethods( [ 'getMessageBuilder', 'getForm' ] ) |
||
| 119 | ->getMock(); |
||
| 120 | |||
| 121 | $htmlFormRenderer->expects( $this->atLeastOnce() ) |
||
| 122 | ->method( 'getMessageBuilder' ) |
||
| 123 | ->will( $this->returnValue( $messageBuilder ) ); |
||
| 124 | |||
| 125 | $this->citationResourceMatchFinder->expects( $this->atLeastOnce() ) |
||
| 126 | ->method( 'findMatchForResourceIdentifierTypeToValue' ) |
||
| 127 | ->will( $this->returnValue( [] ) ); |
||
| 128 | |||
| 129 | $this->httpResponseParserFactory->expects( $this->once() ) |
||
| 130 | ->method( 'newResponseParserForType' ) |
||
| 131 | ->with( $this->stringContains( 'foo') ) |
||
| 132 | ->will( $this->returnValue( $responseParser ) ); |
||
| 133 | |||
| 134 | $instance = new PageBuilder( |
||
| 135 | $htmlFormRenderer, |
||
| 136 | $this->hmlColumnListRenderer, |
||
| 137 | $this->citationResourceMatchFinder, |
||
| 138 | $this->httpResponseParserFactory |
||
| 139 | ); |
||
| 140 | |||
| 141 | $instance->getHtmlFor( 'foo', 42 ); |
||
| 142 | } |
||
| 143 | |||
| 145 |