Passed
Pull Request — master (#305)
by Jaime Pérez
03:35 queued 01:06
created

ExtensionPointTrait::getXsiTypeNamespaceURI()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 2
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\Assert\Assert;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
11
/**
12
 * Trait for several extension points objects.
13
 *
14
 * @package simplesamlphp/saml2
15
 */
16
trait ExtensionPointTrait
17
{
18
    /**
19
     * Get the local name for the element's xsi:type.
20
     *
21
     * @return string
22
     */
23
    public static function getXsiTypeName(): string
24
    {
25
        Assert::true(
26
            defined('static::XSI_TYPE_NAME'),
27
            self::getClassName(static::class)
28
            . '::XSI_TYPE_NAME constant must be defined and set to unprefixed type for the xsi:type it represents.',
29
            RuntimeException::class,
30
        );
31
32
        Assert::validNCName(static::XSI_TYPE_NAME, SchemaViolationException::class);
1 ignored issue
show
Bug introduced by
The constant SimpleSAML\SAML2\XML\Ext...intTrait::XSI_TYPE_NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
        return static::XSI_TYPE_NAME;
34
    }
35
36
37
    /**
38
     * Get the namespace for the element's xsi:type.
39
     *
40
     * @return string
41
     */
42
    public static function getXsiTypeNamespaceURI(): string
43
    {
44
        Assert::true(
45
            defined('static::XSI_TYPE_NAMESPACE'),
46
            self::getClassName(static::class)
47
            . '::XSI_TYPE_NAMESPACE constant must be defined and set to the namespace for the xsi:type it represents.',
48
            RuntimeException::class,
49
        );
50
51
        Assert::validURI(static::XSI_TYPE_NAMESPACE, SchemaViolationException::class);
1 ignored issue
show
Bug introduced by
The constant SimpleSAML\SAML2\XML\Ext...ait::XSI_TYPE_NAMESPACE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
52
        return static::XSI_TYPE_NAMESPACE;
53
    }
54
55
56
    /**
57
     * Get the namespace-prefix for the element's xsi:type.
58
     *
59
     * @return string
60
     */
61
    public static function getXsiTypePrefix(): string
62
    {
63
        Assert::true(
64
            defined('static::XSI_TYPE_PREFIX'),
65
            self::getClassName(static::class)
66
            . '::XSI_TYPE_PREFIX constant must be defined and set to the namespace for the xsi:type it represents.',
67
            RuntimeException::class,
68
        );
69
70
        Assert::validNCName(static::XSI_TYPE_PREFIX, SchemaViolationException::class);
1 ignored issue
show
Bug introduced by
The constant SimpleSAML\SAML2\XML\Ext...tTrait::XSI_TYPE_PREFIX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
71
        return static::XSI_TYPE_PREFIX;
72
    }
73
}
74