AbstractTagImport   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLocationAttributeValue() 0 17 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WsdlToPhp\WsdlHandler\Tag;
6
7
abstract class AbstractTagImport extends Tag
8
{
9
    public const ATTRIBUTE_LOCATION = 'location';
10
    public const ATTRIBUTE_SCHEMA_LOCATION = 'schemaLocation';
11
    public const ATTRIBUTE_SCHEMA_LOCATION_ = 'schemalocation';
12
13 2
    public function getLocationAttributeValue(): string
14
    {
15 2
        $location = '';
16
17 2
        if ($this->hasAttribute(self::ATTRIBUTE_LOCATION)) {
18 2
            $location = $this->getAttributeValue(self::ATTRIBUTE_LOCATION, true);
19 2
        } elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)) {
20 2
            $location = $this->getAttributeValue(self::ATTRIBUTE_SCHEMA_LOCATION, true);
21 2
        } elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)) {
22 2
            $location = $this->getAttributeValue(self::ATTRIBUTE_SCHEMA_LOCATION_, true);
23
        }
24
25 2
        if (!empty($location) && './' === mb_substr($location, 0, 2)) {
0 ignored issues
show
Bug introduced by
It seems like $location can also be of type boolean; however, parameter $string of mb_substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

25
        if (!empty($location) && './' === mb_substr(/** @scrutinizer ignore-type */ $location, 0, 2)) {
Loading history...
26 2
            $location = mb_substr($location, 2);
27
        }
28
29 2
        return $location;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $location could return the type boolean|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
30
    }
31
}
32