KeySize   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
dl 0
loc 28
c 1
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateContent() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wst_200502;
6
7
use SimpleSAML\WSSecurity\Assert\Assert;
8
use SimpleSAML\XML\Exception\SchemaViolationException;
9
use SimpleSAML\XML\IntegerElementTrait;
10
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
11
12
/**
13
 * Class representing WS-trust KeySize.
14
 *
15
 * @package simplesamlphp/ws-security
16
 */
17
final class KeySize extends AbstractWstElement implements SchemaValidatableElementInterface
18
{
19
    use IntegerElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\IntegerElementTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\wst_200502\KeySize: $localName, $namespaceURI
Loading history...
20
    use SchemaValidatableElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\wst_200502\KeySize: $message, $line
Loading history...
21
22
    /**
23
     * KeySize constructor.
24
     *
25
     * @param string $value The long.
26
     */
27
    final public function __construct(string $value)
28
    {
29
        $this->setContent($value);
30
    }
31
32
33
    /**
34
     * Validate the content of the element.
35
     *
36
     * @param string $content  The value to go in the XML textContent
37
     * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
38
     * @return void
39
     */
40
    protected function validateContent(string $content): void
41
    {
42
        $content = intval($content);
43
        Assert::natural($content, SchemaViolationException::class);
44
        Assert::range($content, 0, 4294967295, SchemaViolationException::class);
45
    }
46
}
47