Tag   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasRestrictionChild() 0 3 1
A getFirstRestrictionChild() 0 3 1
A isTheParent() 0 5 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WsdlToPhp\WsdlHandler\Tag;
6
7
use WsdlToPhp\WsdlHandler\AbstractDocument;
8
use WsdlToPhp\WsdlHandler\Tag\TagRestriction as Restriction;
9
10
class Tag extends AbstractTag
11
{
12 2
    public function hasRestrictionChild(): bool
13
    {
14 2
        return $this->getFirstRestrictionChild() instanceof Restriction;
15
    }
16
17 8
    public function getFirstRestrictionChild(): ?TagRestriction
18
    {
19 8
        return $this->getChildByNameAndAttributes(AbstractDocument::TAG_RESTRICTION, []);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getChildBy...G_RESTRICTION, array()) could return the type WsdlToPhp\DomHandler\ElementHandler which includes types incompatible with the type-hinted return WsdlToPhp\WsdlHandler\Tag\TagRestriction|null. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
22
    /**
23
     * Checks if the given tag is the same direct parent of this current tag.
24
     */
25 4
    public function isTheParent(AbstractTag $tag): bool
26
    {
27 4
        $parent = $this->getSuitableParent();
28
29 4
        return $parent ? $parent->getNode()->isSameNode($tag->getNode()) : false;
0 ignored issues
show
introduced by
$parent is of type WsdlToPhp\DomHandler\ElementHandler, thus it always evaluated to true.
Loading history...
30
    }
31
}
32