AbstractTagImport::getLocationAttributeValue()   A
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 6

Importance

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