Tag::hasRestrictionChild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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