| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 44 |
| 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 |
||
| 9 | public function testStandardGettersAndSetters() |
||
| 10 | { |
||
| 11 | $page = new \Page\Entity\Page(); |
||
| 12 | |||
| 13 | $date = date('d.m.Y', time()); |
||
| 14 | $dateFormatted = date('Y/m/d', time()); |
||
| 15 | |||
| 16 | $page->setBody('test'); |
||
| 17 | $page->setCreatedAt($date); |
||
| 18 | $page->setDescription('test'); |
||
| 19 | $page->setHasLayout(1); |
||
| 20 | $page->setIsActive(1); |
||
| 21 | $page->setIsHomepage(1); |
||
| 22 | $page->setIsWysiwygEditor(1); |
||
| 23 | $page->setMainImg('test'); |
||
| 24 | $page->setPageId(1); |
||
| 25 | $page->setPageUuid('test'); |
||
| 26 | $page->setSlug('test'); |
||
| 27 | $page->setTitle('test'); |
||
| 28 | |||
| 29 | static::assertSame('test', $page->getBody()); |
||
| 30 | static::assertSame($date, $page->getCreatedAt()); |
||
| 31 | static::assertSame($dateFormatted, $page->getCreatedAt('Y/m/d')); |
||
| 32 | static::assertSame('test', $page->getDescription()); |
||
| 33 | static::assertSame('te', $page->getDescription(2)); |
||
| 34 | static::assertSame(1, $page->getHasLayout()); |
||
| 35 | static::assertSame(1, $page->getIsActive()); |
||
| 36 | static::assertSame(1, $page->getIsHomepage()); |
||
| 37 | static::assertSame(1, $page->getIsWysiwygEditor()); |
||
| 38 | static::assertSame(1, $page->getPageId()); |
||
| 39 | static::assertSame('test', $page->getMainImg()); |
||
| 40 | static::assertSame('test', $page->getPageUuid()); |
||
| 41 | static::assertSame('test', $page->getSlug()); |
||
| 42 | static::assertSame('test', $page->getTitle()); |
||
| 43 | static::assertSame( |
||
| 44 | [ |
||
| 45 | 'page_uuid' => 'test', |
||
| 46 | 'page_id' => '1', |
||
| 47 | 'title' => 'test', |
||
| 48 | 'body' => 'test', |
||
| 49 | 'description' => 'test', |
||
| 50 | 'main_img' => 'test', |
||
| 51 | 'has_layout' => true, |
||
| 52 | 'is_homepage' => true, |
||
| 53 | 'is_active' => true, |
||
| 54 | 'is_wysiwyg_editor' => true, |
||
| 55 | 'created_at' => $date, |
||
| 56 | 'slug' => 'test', |
||
| 57 | ], $page->getArrayCopy() |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |