| Conditions | 2 |
| Paths | 2 |
| Total Lines | 62 |
| Code Lines | 47 |
| 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 |
||
| 99 | private function validateFacebookOpenGraphData(bool $fullRequirements = false) |
||
| 100 | { |
||
| 101 | Assert::assertNotFalse( |
||
| 102 | filter_var($this->getOGMetaContent('og:url'), FILTER_VALIDATE_URL) |
||
| 103 | ); |
||
| 104 | |||
| 105 | Assert::assertEquals( |
||
| 106 | $this->getOGMetaContent('og:url'), |
||
| 107 | $this->getCurrentUrl(), |
||
| 108 | 'OG meta og:url does not match expected url' |
||
| 109 | ); |
||
| 110 | |||
| 111 | $this->getOGMetaContent('og:title'); |
||
| 112 | $this->getOGMetaContent('og:description'); |
||
| 113 | |||
| 114 | Assert::assertNotFalse( |
||
| 115 | filter_var($this->getOGMetaContent('og:image'), FILTER_VALIDATE_URL) |
||
| 116 | ); |
||
| 117 | |||
| 118 | Assert::assertContains( |
||
| 119 | pathinfo($this->getOGMetaContent('og:image'))['extension'], |
||
| 120 | ['jpg', 'jpeg', 'png', 'gif'], |
||
| 121 | 'OG meta og:image has valid extension. Allowed are: jpg/jpeg, png, gif' |
||
| 122 | ); |
||
| 123 | |||
| 124 | if ($fullRequirements) { |
||
| 125 | Assert::assertContains( |
||
| 126 | $this->getOGMetaContent('og:type'), |
||
| 127 | [ |
||
| 128 | 'article', |
||
| 129 | 'book', |
||
| 130 | 'books.author', |
||
| 131 | 'books.book', |
||
| 132 | 'books.genre', |
||
| 133 | 'business.business', |
||
| 134 | 'fitness.course', |
||
| 135 | 'game.achievement', |
||
| 136 | 'music.album', |
||
| 137 | 'music.playlist', |
||
| 138 | 'music.radio_station', |
||
| 139 | 'music.song', |
||
| 140 | 'place', |
||
| 141 | 'product', |
||
| 142 | 'product.group', |
||
| 143 | 'product.item', |
||
| 144 | 'profile', |
||
| 145 | 'restaurant.menu', |
||
| 146 | 'restaurant.menu_item', |
||
| 147 | 'restaurant.menu_section', |
||
| 148 | 'restaurant.restaurant', |
||
| 149 | 'video.episode', |
||
| 150 | 'video.movie', |
||
| 151 | 'video.other', |
||
| 152 | 'video.tv_show', |
||
| 153 | ], |
||
| 154 | 'OG meta og:type contains invalid content.' |
||
| 155 | ); |
||
| 156 | |||
| 157 | Assert::assertRegExp( |
||
| 158 | '/^[a-z]{2}_[A-Z]{2}$/', |
||
| 159 | $this->getOGMetaContent('og:locale'), |
||
| 160 | 'OG meta og:locale does not follow the right format az_AZ.' |
||
| 161 | ); |
||
| 165 |