Title::removeInvalidChildren()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 14
loc 14
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 4
nop 1
crap 4
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\ElementTypes\MetadataContent;
6
use Groundskeeper\Tokens\ElementTypes\OpenElement;
7
use Groundskeeper\Tokens\NonParticipating;
8
use Groundskeeper\Tokens\Text;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "title" element
13
 */
14
class Title extends OpenElement implements MetadataContent
15
{
16 31 View Code Duplication
    protected function removeInvalidChildren(LoggerInterface $logger)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        // TITLE must contain only non-whitespace text or comments.
19 31
        foreach ($this->children as $child) {
20 28
            if ($child instanceof NonParticipating) {
21 1
                continue;
22
            }
23
24 28
            if (!$child instanceof Text) {
25 1
                $logger->debug('Removing ' . $child . '. Only text allowed inside TITLE.');
26 28
                $this->removeChild($child);
27
            }
28
        }
29 31
    }
30
}
31