| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 3 | public function check(Subject $subject): ResultCollection |
|
| 26 | { |
||
| 27 | 3 | $resultCollection = new ResultCollection(); |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Check |
||
| 31 | */ |
||
| 32 | 3 | $contextDescription = $subject->getContextDescription(); |
|
| 33 | |||
| 34 | 3 | $titleTags = $subject->getDom()->getElementsByTagName('title'); |
|
| 35 | |||
| 36 | 3 | if ($titleTags->length === 0) { |
|
| 37 | 1 | $resultCollection->add(new Result($contextDescription, 'Title tag is missing')); |
|
| 38 | |||
| 39 | 2 | } else if ($titleTags->length === 1) { |
|
| 40 | 1 | if (strlen($titleTags->item(0)->nodeValue) > 55) { |
|
| 41 | 1 | $resultCollection->add(new Result($contextDescription, 'Title is longer than 55 characters')); |
|
| 42 | } |
||
| 43 | } else { |
||
| 44 | 1 | $resultCollection->add(new Result($contextDescription, 'There are more than one title tag')); |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | return $resultCollection; |
|
| 48 | } |
||
| 49 | } |
||
| 50 |