ExtensionPointTrait::getXsiTypeNamespaceURI()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML;
6
7
use RuntimeException;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\XMLSchema\Type\AnyURIValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\AnyURIValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SimpleSAML\XMLSchema\Type\NCNameValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\NCNameValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
use function constant;
13
use function defined;
14
use function sprintf;
15
16
/**
17
 * Trait for several extension points objects.
18
 *
19
 * @package simplesamlphp/saml2
20
 */
21
trait ExtensionPointTrait
22
{
23
    /**
24
     * Get the local name for the element's xsi:type.
25
     *
26
     * @return \SimpleSAML\XMLSchema\Type\NCNameValue
27
     */
28
    public static function getXsiTypeName(): NCNameValue
29
    {
30
        Assert::true(
31
            defined('static::XSI_TYPE_NAME'),
32
            self::getClassName(static::class)
33
            . '::XSI_TYPE_NAME constant must be defined and set to unprefixed type for the xsi:type it represents.',
34
            RuntimeException::class,
35
        );
36
37
        return NCNameValue::fromString(constant('static::XSI_TYPE_NAME'));
38
    }
39
40
41
    /**
42
     * Get the namespace for the element's xsi:type.
43
     *
44
     * @return \SimpleSAML\XMLSchema\Type\AnyURIValue
45
     */
46
    public static function getXsiTypeNamespaceURI(): AnyURIValue
47
    {
48
        Assert::true(
49
            defined('static::XSI_TYPE_NAMESPACE'),
50
            self::getClassName(static::class)
51
            . '::XSI_TYPE_NAMESPACE constant must be defined and set to the namespace for the xsi:type it represents.',
52
            RuntimeException::class,
53
        );
54
55
        return AnyURIValue::fromString(constant('static::XSI_TYPE_NAMESPACE'));
56
    }
57
58
59
    /**
60
     * Get the namespace-prefix for the element's xsi:type.
61
     *
62
     * @return \SimpleSAML\XMLSchema\Type\NCNameValue
63
     */
64
    public static function getXsiTypePrefix(): NCNameValue
65
    {
66
        Assert::true(
67
            defined('static::XSI_TYPE_PREFIX'),
68
            sprintf(
69
                '%s::XSI_TYPE_PREFIX constant must be defined and set to the namespace for the xsi:type it represents.',
70
                self::getClassName(static::class),
71
            ),
72
            RuntimeException::class,
73
        );
74
75
        return NCNameValue::fromString(constant('static::XSI_TYPE_PREFIX'));
76
    }
77
}
78