AbstractTagOperationElement   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 58
ccs 28
cts 28
cp 1
rs 10
wmc 13

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeMessage() 0 3 2
A getParentOperation() 0 3 1
A hasAttributeMessage() 0 3 1
A getPart() 0 9 3
A getParts() 0 9 2
A getAttributeMessageNamespace() 0 3 2
A getMessage() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WsdlToPhp\WsdlHandler\Tag;
6
7
use WsdlToPhp\WsdlHandler\AbstractDocument;
8
9
abstract class AbstractTagOperationElement extends Tag
10
{
11
    public const ATTRIBUTE_MESSAGE = 'message';
12
13 2
    public function getParentOperation(): ?TagOperation
14
    {
15 2
        return $this->getStrictParent(AbstractDocument::TAG_OPERATION);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getStrictP...ocument::TAG_OPERATION) returns the type WsdlToPhp\DomHandler\ElementHandler which includes types incompatible with the type-hinted return WsdlToPhp\WsdlHandler\Tag\TagOperation|null.
Loading history...
16
    }
17
18 20
    public function hasAttributeMessage(): bool
19
    {
20 20
        return $this->hasAttribute(self::ATTRIBUTE_MESSAGE);
21
    }
22
23 20
    public function getAttributeMessage(): string
24
    {
25 20
        return $this->hasAttributeMessage() ? $this->getAttribute(self::ATTRIBUTE_MESSAGE)->getValue() : '';
26
    }
27
28 2
    public function getAttributeMessageNamespace(): ?string
29
    {
30 2
        return $this->hasAttribute(self::ATTRIBUTE_MESSAGE) ? $this->getAttribute(self::ATTRIBUTE_MESSAGE)->getValueNamespace() : null;
31
    }
32
33 18
    public function getMessage(): ?TagMessage
34
    {
35 18
        $message = null;
36 18
        $messageName = $this->getAttributeMessage();
37
38 18
        if (!empty($messageName)) {
39 18
            $message = $this->getDomDocumentHandler()->getElementByNameAndAttributes(AbstractDocument::TAG_MESSAGE, [
40 18
                'name' => $messageName,
41 18
            ], true);
0 ignored issues
show
Unused Code introduced by
The call to WsdlToPhp\DomHandler\Abs...ntByNameAndAttributes() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
            $message = $this->getDomDocumentHandler()->/** @scrutinizer ignore-call */ getElementByNameAndAttributes(AbstractDocument::TAG_MESSAGE, [

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
42
        }
43
44 18
        return $message;
45
    }
46
47 2
    public function getParts(): ?array
48
    {
49 2
        $parts = null;
50 2
        $message = $this->getMessage();
51 2
        if ($message instanceof TagMessage) {
52 2
            $parts = $message->getChildrenByName(AbstractDocument::TAG_PART);
53
        }
54
55 2
        return $parts;
56
    }
57
58 14
    public function getPart(string $partName): ?TagPart
59
    {
60 14
        $part = null;
61 14
        $message = $this->getMessage();
62 14
        if ($message instanceof TagMessage && !empty($partName)) {
63 14
            $part = $message->getPart($partName);
64
        }
65
66 14
        return $part;
67
    }
68
}
69