| Conditions | 1 |
| Paths | 1 |
| Total Lines | 91 |
| Code Lines | 71 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 35 | public function responsesProvider() { |
||
| 36 | $tests = array(); |
||
| 37 | |||
| 38 | $handlerMock = $this->getMockForAbstractClass('PPP\Module\AbstractRequestHandler'); |
||
| 39 | $handlerMock->expects($this->any()) |
||
| 40 | ->method('buildResponse') |
||
| 41 | ->with($this->equalTo(new ModuleRequest('en', new MissingNode(), 'a'))) |
||
| 42 | ->will($this->returnValue(array())); |
||
| 43 | $tests[] = array( |
||
| 44 | $handlerMock, |
||
| 45 | '{"language":"en","tree":{"type":"missing"},"id":"a"}', |
||
| 46 | '[]' |
||
| 47 | ); |
||
| 48 | |||
| 49 | $handlerMock = $this->getMockForAbstractClass('PPP\Module\AbstractRequestHandler'); |
||
| 50 | $handlerMock->expects($this->any()) |
||
| 51 | ->method('buildResponse') |
||
| 52 | ->with($this->equalTo(new ModuleRequest('en', new MissingNode(), 'a'))) |
||
| 53 | ->will($this->returnValue(array(new ModuleResponse( |
||
| 54 | 'en', |
||
| 55 | new ResourceListNode(array(new StringResourceNode('p'))), |
||
| 56 | array('accuracy' => 1) |
||
| 57 | )))); |
||
| 58 | $tests[] = array( |
||
| 59 | $handlerMock, |
||
| 60 | '{"language":"en","tree":{"type":"missing"},"id":"a"}', |
||
| 61 | '[{"language":"en","tree":{"type":"resource","value":"p","value-type":"string"},"measures":{"accuracy":1},"trace":[]}]' |
||
| 62 | ); |
||
| 63 | |||
| 64 | $handlerMock = $this->getMockForAbstractClass('PPP\Module\AbstractRequestHandler'); |
||
| 65 | $handlerMock->expects($this->any()) |
||
| 66 | ->method('buildResponse') |
||
| 67 | ->with($this->equalTo(new ModuleRequest('en', new MissingNode(), 'a'))) |
||
| 68 | ->will($this->returnValue(array( |
||
| 69 | new ModuleResponse( |
||
| 70 | 'en', |
||
| 71 | new ResourceListNode(array(new StringResourceNode('p'))), |
||
| 72 | array('accuracy' => 1) |
||
| 73 | ), |
||
| 74 | new ModuleResponse( |
||
| 75 | 'en', |
||
| 76 | new ResourceListNode(array(new StringResourceNode('p'))), |
||
| 77 | array('accuracy' => 0.9) |
||
| 78 | ) |
||
| 79 | ))); |
||
| 80 | $tests[] = array( |
||
| 81 | $handlerMock, |
||
| 82 | '{"language":"en","tree":{"type":"missing"},"id":"a"}', |
||
| 83 | '[{"language":"en","tree":{"type":"resource","value":"p","value-type":"string"},"measures":{"accuracy":1},"trace":[]}]' |
||
| 84 | ); |
||
| 85 | |||
| 86 | $handlerMock = $this->getMockForAbstractClass('PPP\Module\AbstractRequestHandler'); |
||
| 87 | $handlerMock->expects($this->any()) |
||
| 88 | ->method('buildResponse') |
||
| 89 | ->with($this->equalTo(new ModuleRequest('en', new MissingNode(), 'a', array('accuracy' => 1)))) |
||
| 90 | ->will($this->returnValue(array(new ModuleResponse('en', new ResourceListNode(array(new StringResourceNode('p'))))))); |
||
| 91 | $tests[] = array( |
||
| 92 | $handlerMock, |
||
| 93 | '{"language":"en","tree":{"type":"missing"},"measures":{"accuracy":1},"id":"a"}', |
||
| 94 | '[{"language":"en","tree":{"type":"resource","value":"p","value-type":"string"},"measures":{"accuracy":1},"trace":[]}]' |
||
| 95 | ); |
||
| 96 | |||
| 97 | $handlerMock = $this->getMockForAbstractClass('PPP\Module\AbstractRequestHandler'); |
||
| 98 | $handlerMock->expects($this->any()) |
||
| 99 | ->method('buildResponse') |
||
| 100 | ->with($this->equalTo(new ModuleRequest( |
||
| 101 | 'en', |
||
| 102 | new TripleNode( |
||
| 103 | new ResourceListNode(array(new StringResourceNode('s'))), |
||
| 104 | new ResourceListNode(array(new StringResourceNode('p'))), |
||
| 105 | new ResourceListNode(array(new StringResourceNode('o'))) |
||
| 106 | ), |
||
| 107 | 'a' |
||
| 108 | ))) |
||
| 109 | ->will($this->returnValue(array(new ModuleResponse( |
||
| 110 | 'en', |
||
| 111 | new TripleNode( |
||
| 112 | new ResourceListNode(array(new StringResourceNode('s1'))), |
||
| 113 | new ResourceListNode(array(new StringResourceNode('p1'))), |
||
| 114 | new ResourceListNode(array(new StringResourceNode('o1'))) |
||
| 115 | ), |
||
| 116 | array('accuracy' => 1) |
||
| 117 | )))); |
||
| 118 | $tests[] = array( |
||
| 119 | $handlerMock, |
||
| 120 | '{"language":"en","tree":{"type":"triple","subject":{"type":"resource","value":"s","value-type":"string"},"predicate":{"type":"resource","value":"p","value-type":"string"},"object":{"type":"resource","value":"o","value-type":"string"}},"id":"a"}', |
||
| 121 | '[{"language":"en","tree":{"type":"triple","subject":{"type":"resource","value":"s1","value-type":"string"},"predicate":{"type":"resource","value":"p1","value-type":"string"},"object":{"type":"resource","value":"o1","value-type":"string"}},"measures":{"accuracy":1},"trace":[]}]' |
||
| 122 | ); |
||
| 123 | |||
| 124 | return $tests; |
||
| 125 | } |
||
| 126 | |||
| 156 |