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