| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 47 |
| 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 declare(strict_types = 1); |
||
| 33 | public function testGetIndexes(): void |
||
| 34 | { |
||
| 35 | $indexes = new Indexes(); |
||
| 36 | $indices = $indexes->getIndexes(); |
||
| 37 | |||
| 38 | $this->assertEquals('sitetree', $indices['sitetree']->getName()); |
||
| 39 | $this->assertEquals([ |
||
| 40 | 'Title', |
||
| 41 | 'Content', |
||
| 42 | 'ParentID', |
||
| 43 | 'MenuTitle', |
||
| 44 | 'Sort', |
||
| 45 | 'Created', |
||
| 46 | 'LastEdited', |
||
| 47 | ], $indices['sitetree']->getFields()); |
||
| 48 | $this->assertEquals([], $indices['sitetree']->getHasOneFields()); |
||
| 49 | $this->assertEquals([], $indices['sitetree']->getHasManyFields()); |
||
| 50 | $this->assertEquals([], $indices['sitetree']->getTokens()); |
||
| 51 | |||
| 52 | $this->assertEquals(['Title', 'Content'], $indices['sitetree']->getHighlightedFields()); |
||
| 53 | $this->assertEquals(['Link'], $indices['sitetree']->getStoredFields()); |
||
| 54 | |||
| 55 | $this->assertEquals('members', $indices['members']->getName()); |
||
| 56 | $this->assertEquals([ |
||
| 57 | 'FirstName', |
||
| 58 | 'Surname', |
||
| 59 | 'Email', |
||
| 60 | ], $indices['members']->getFields()); |
||
| 61 | $this->assertEquals([], $indices['members']->getHasOneFields()); |
||
| 62 | $this->assertEquals([], $indices['members']->getHasManyFields()); |
||
| 63 | $this->assertEquals([], $indices['members']->getTokens()); |
||
| 64 | |||
| 65 | $this->assertEquals('flickrphotos', $indices['flickrphotos']->getName()); |
||
| 66 | $this->assertEquals([ |
||
| 67 | 'Title', |
||
| 68 | 'Description', |
||
| 69 | ], $indices['flickrphotos']->getFields()); |
||
| 70 | $this->assertEquals( |
||
| 71 | [ |
||
| 72 | 'Photographer' => [ |
||
| 73 | 'relationship' => 'Photographer', |
||
| 74 | 'field' => 'PathAlias', |
||
| 75 | 'class' => 'Suilven\FreeTextSearch\Tests\Models\FlickrAuthor', |
||
| 76 | ], |
||
| 77 | ], |
||
| 78 | $indices['flickrphotos']->getHasOneFields() |
||
| 79 | ); |
||
| 80 | $this->assertEquals(['tags' => |
||
| 81 | [ |
||
| 82 | 'relationship' => 'FlickrTags', |
||
| 83 | 'field' => 'RawValue', |
||
| 84 | 'class' => 'Suilven\FreeTextSearch\Tests\Models\FlickrTag', |
||
| 85 | ]], $indices['flickrphotos']->getHasManyFields()); |
||
| 86 | $this->assertEquals([ |
||
| 87 | 'Aperture', |
||
| 88 | 'ShutterSpeed', |
||
| 89 | 'ISO', |
||
| 90 | ], $indices['flickrphotos']->getTokens()); |
||
| 91 | } |
||
| 141 |