| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 37 | public function testSortingOnResourceSave() |
||
| 38 | { |
||
| 39 | $this->moveFieldFixture('subject', 1); |
||
| 40 | |||
| 41 | /** @var Resource $resource */ |
||
| 42 | $resource = $this->objFromFixture(Resource::class, 'teachers'); |
||
| 43 | |||
| 44 | $this->assertArrayEqualsInOrder( |
||
| 45 | [ |
||
| 46 | 'Subject' => '1', |
||
| 47 | 'First name' => '2', |
||
| 48 | 'Last name' => '3', |
||
| 49 | 'City' => '4', |
||
| 50 | 'School' => '5', |
||
| 51 | 'Gender' => '6', |
||
| 52 | ], |
||
| 53 | $resource->Fields()->sort('Position', 'ASC')->map('OriginalLabel', 'Position')->toArray() |
||
| 54 | ); |
||
| 55 | |||
| 56 | $this->moveFieldFixture('firstname', 5); |
||
| 57 | |||
| 58 | $this->assertArrayEqualsInOrder( |
||
| 59 | [ |
||
| 60 | 'Subject' => '1', |
||
| 61 | 'Last name' => '2', |
||
| 62 | 'City' => '3', |
||
| 63 | 'School' => '4', |
||
| 64 | 'First name' => '5', |
||
| 65 | 'Gender' => '6', |
||
| 66 | ], |
||
| 67 | $resource->Fields()->sort('Position', 'ASC')->map('OriginalLabel', 'Position')->toArray() |
||
| 68 | ); |
||
| 69 | |||
| 70 | $this->moveFieldFixture('subject', 9); |
||
| 71 | |||
| 72 | $this->assertArrayEqualsInOrder( |
||
| 73 | [ |
||
| 74 | 'Last name' => '1', |
||
| 75 | 'City' => '2', |
||
| 76 | 'School' => '3', |
||
| 77 | 'First name' => '4', |
||
| 78 | 'Gender' => '5', |
||
| 79 | 'Subject' => '9', |
||
| 80 | ], |
||
| 81 | $resource->Fields()->sort('Position', 'ASC')->map('OriginalLabel', 'Position')->toArray() |
||
| 82 | ); |
||
| 83 | |||
| 84 | $this->moveFieldFixture('gender', 1); |
||
| 85 | |||
| 86 | $this->assertArrayEqualsInOrder( |
||
| 87 | [ |
||
| 88 | 'Gender' => '1', |
||
| 89 | 'Last name' => '2', |
||
| 90 | 'City' => '3', |
||
| 91 | 'School' => '4', |
||
| 92 | 'First name' => '5', |
||
| 93 | 'Subject' => '9', |
||
| 94 | ], |
||
| 95 | $resource->Fields()->sort('Position', 'ASC')->map('OriginalLabel', 'Position')->toArray() |
||
| 96 | ); |
||
| 155 |