| Conditions | 1 |
| Paths | 1 |
| Total Lines | 85 |
| Code Lines | 67 |
| 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 |
||
| 30 | public function validProvider() { |
||
| 31 | $withItemLookupMock = $this->getMock('Wikibase\DataModel\Services\Lookup\ItemLookup'); |
||
| 32 | $withItemLookupMock->expects($this->once()) |
||
| 33 | ->method('getItemForId') |
||
| 34 | ->with($this->equalTo(new ItemId('Q42'))) |
||
| 35 | ->willReturn(new Item( |
||
| 36 | new ItemId('Q42'), |
||
| 37 | new Fingerprint(new TermList(array(new Term('en', 'Douglas Adams')))) |
||
| 38 | )); |
||
| 39 | $withoutItemLookupMock = $this->getMock('Wikibase\DataModel\Services\Lookup\ItemLookup'); |
||
| 40 | $withoutItemLookupMock->expects($this->once()) |
||
| 41 | ->method('getItemForId') |
||
| 42 | ->with($this->equalTo(new ItemId('Q42'))) |
||
| 43 | ->willReturn(null); |
||
| 44 | |||
| 45 | $withPropertyLookupMock = $this->getMock('Wikibase\DataModel\Services\Lookup\PropertyLookup'); |
||
| 46 | $withPropertyLookupMock->expects($this->once()) |
||
| 47 | ->method('getPropertyForId') |
||
| 48 | ->with($this->equalTo(new PropertyId('P214'))) |
||
| 49 | ->willReturn(new Property( |
||
| 50 | new PropertyId('P214'), |
||
| 51 | new Fingerprint(new TermList(array(new Term('en', 'VIAF')))), |
||
| 52 | 'string' |
||
| 53 | )); |
||
| 54 | $withoutPropertyLookupMock = $this->getMock('Wikibase\DataModel\Services\Lookup\PropertyLookup'); |
||
| 55 | $withoutPropertyLookupMock->expects($this->once()) |
||
| 56 | ->method('getPropertyForId') |
||
| 57 | ->with($this->equalTo(new PropertyId('P214'))) |
||
| 58 | ->willReturn(null); |
||
| 59 | |||
| 60 | return array( |
||
| 61 | array( |
||
| 62 | new EntityIdValue(new ItemId('Q42')), |
||
| 63 | (object) array( |
||
| 64 | '@type' => 'Thing', |
||
| 65 | '@id' => 'http://www.wikidata.org/entity/Q42', |
||
| 66 | 'name' => (object) array('@value' => 'Douglas Adams', '@language' => 'en') |
||
| 67 | ), |
||
| 68 | null, |
||
| 69 | $this->getFormatter( |
||
| 70 | $withItemLookupMock, |
||
| 71 | $this->getMock('Wikibase\DataModel\Services\Lookup\PropertyLookup') |
||
| 72 | ) |
||
| 73 | ), |
||
| 74 | array( |
||
| 75 | new EntityIdValue(new ItemId('Q42')), |
||
| 76 | (object) array( |
||
| 77 | '@type' => 'Thing', |
||
| 78 | '@id' => 'http://www.wikidata.org/entity/Q42', |
||
| 79 | 'name' => 'Q42' |
||
| 80 | ), |
||
| 81 | null, |
||
| 82 | $this->getFormatter( |
||
| 83 | $withoutItemLookupMock, |
||
| 84 | $this->getMock('Wikibase\DataModel\Services\Lookup\PropertyLookup') |
||
| 85 | ) |
||
| 86 | ), |
||
| 87 | array( |
||
| 88 | new EntityIdValue(new PropertyId('P214')), |
||
| 89 | (object) array( |
||
| 90 | '@type' => 'Property', |
||
| 91 | '@id' => 'http://www.wikidata.org/entity/P214', |
||
| 92 | 'name' => (object) array('@value' => 'VIAF', '@language' => 'en') |
||
| 93 | ), |
||
| 94 | null, |
||
| 95 | $this->getFormatter( |
||
| 96 | $this->getMock('Wikibase\DataModel\Services\Lookup\ItemLookup'), |
||
| 97 | $withPropertyLookupMock |
||
| 98 | ) |
||
| 99 | ), |
||
| 100 | array( |
||
| 101 | new EntityIdValue(new PropertyId('P214')), |
||
| 102 | (object) array( |
||
| 103 | '@type' => 'Property', |
||
| 104 | '@id' => 'http://www.wikidata.org/entity/P214', |
||
| 105 | 'name' => 'P214' |
||
| 106 | ), |
||
| 107 | null, |
||
| 108 | $this->getFormatter( |
||
| 109 | $this->getMock('Wikibase\DataModel\Services\Lookup\ItemLookup'), |
||
| 110 | $withoutPropertyLookupMock |
||
| 111 | ) |
||
| 112 | ) |
||
| 113 | ); |
||
| 114 | } |
||
| 115 | |||
| 138 |