Completed
Push — develop ( 9c1b40...ded088 )
by Mikaël
39:36 queued 16:56
created

Tag::isTheParent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WsdlToPhp\PackageGenerator\WsdlHandler\Tag;
4
5
use WsdlToPhp\PackageGenerator\WsdlHandler\AbstractDocument;
6
use WsdlToPhp\PackageGenerator\WsdlHandler\Tag\TagRestriction as Restriction;
7
8
class Tag extends AbstractTag
9
{
10
11
    /**
12
     * @return bool
13
     */
14 42
    public function hasRestrictionChild()
15
    {
16 42
        return $this->getFirstRestrictionChild() instanceof Restriction;
17
    }
18
19
    /**
20
     * @return Restriction|null
21
     */
22 42
    public function getFirstRestrictionChild()
23
    {
24 42
        return $this->getChildByNameAndAttributes(AbstractDocument::TAG_RESTRICTION, []);
25
    }
26
27
    /**
28
     * Checks if the given tag is the same direct parent of this current tag
29
     * @param AbstractTag $tag
30
     * @return bool
31
     */
32 24
    public function isTheParent(AbstractTag $tag)
33
    {
34
        /** @var AbstractTag|null $parent */
35 24
        $parent = $this->getSuitableParent();
36 24
        return $parent ? $parent->getNode()->isSameNode($tag->getNode()) : false;
0 ignored issues
show
introduced by
$parent is of type WsdlToPhp\PackageGenerat...Handler\Tag\AbstractTag, thus it always evaluated to true.
Loading history...
37
    }
38
}
39