Passed
Push — master ( 4a55a4...e4f35a )
by Tim
02:31
created

CodeValue::toEnum()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\Type;
6
7
use SimpleSAML\CAS\XML\Enumeration\ErrorEnum;
8
use SimpleSAML\XMLSchema\Type\StringValue;
9
10
/**
11
 * @package simplesaml/xml-cas
12
 */
13
class CodeValue extends StringValue
14
{
15
    public const string SCHEMA_TYPE = 'string';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 15 at column 24
Loading history...
16
17
18
    /**
19
     * @param \SimpleSAML\CAS\XML\Enumeration\ErrorEnum $value
20
     * @return static
21
     */
22
    public static function fromEnum(ErrorEnum $value): static
23
    {
24
        return new static($value->value);
25
    }
26
27
28
    /**
29
     * @return \SimpleSAML\CAS\XML\Enumeration\ErrorEnum|null $value
30
     */
31
    public function toEnum(): ?ErrorEnum
32
    {
33
        return ErrorEnum::tryFrom($this->getValue());
34
    }
35
}
36