Conditions | 2 |
Paths | 2 |
Total Lines | 56 |
Code Lines | 31 |
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 |
||
62 | public function testItemObjectModel() |
||
63 | { |
||
64 | $itemObjectModel = new ItemObjectModel($this->getItems()); |
||
65 | $this->assertInstanceOf(ItemObjectModel::class, $itemObjectModel); |
||
66 | |||
67 | // Test all LinkRel items |
||
68 | $rels = $itemObjectModel->rel(); |
||
69 | $this->assertEquals(2, count($rels)); |
||
70 | foreach ($rels as $rel) { |
||
71 | $this->assertInstanceOf(ItemInterface::class, $rel); |
||
72 | } |
||
73 | |||
74 | // Test the second LinkRel item |
||
75 | $secondRel = $itemObjectModel->rel(null, 1); |
||
76 | $this->assertInstanceOf(Item::class, $secondRel); |
||
77 | $this->assertEquals( |
||
78 | [ |
||
79 | (object)[ |
||
80 | 'name' => 'alternate', |
||
81 | 'profile' => LinkRel::HTML_PROFILE_URI |
||
82 | ] |
||
83 | ], |
||
84 | $secondRel->getType() |
||
85 | ); |
||
86 | |||
87 | // Test all stylesheet LinkRel items |
||
88 | $stylesheetRels = $itemObjectModel->rel('stylesheet'); |
||
89 | $this->assertTrue(is_array($stylesheetRels)); |
||
90 | $this->assertEquals(1, count($stylesheetRels)); |
||
91 | $this->assertInstanceOf(Item::class, $stylesheetRels[0]); |
||
92 | $this->assertEquals( |
||
93 | [ |
||
94 | (object)[ |
||
95 | 'name' => 'stylesheet', |
||
96 | 'profile' => LinkRel::HTML_PROFILE_URI |
||
97 | ] |
||
98 | ], |
||
99 | $stylesheetRels[0]->getType() |
||
100 | ); |
||
101 | |||
102 | // Test the first stylesheet LinkRel item |
||
103 | $firstStylesheetRel = $itemObjectModel->rel('stylesheet', 0); |
||
104 | $this->assertInstanceOf(Item::class, $firstStylesheetRel); |
||
105 | $this->assertEquals( |
||
106 | [ |
||
107 | (object)[ |
||
108 | 'name' => 'stylesheet', |
||
109 | 'profile' => LinkRel::HTML_PROFILE_URI |
||
110 | ] |
||
111 | ], |
||
112 | $firstStylesheetRel->getType() |
||
113 | ); |
||
114 | |||
115 | // Test an invalid item index |
||
116 | $itemObjectModel->rel('stylesheet', 1); |
||
117 | } |
||
118 | |||
199 |