Completed
Push — 8.7 ( 735e8a...e29d62 )
by Markus
08:22 queued 05:11
created

FrontendUser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
c 1
b 0
f 0
dl 0
loc 31
ccs 13
cts 14
cp 0.9286
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 3 1
A __construct() 0 3 1
A hasProperty() 0 3 1
A getUid() 0 3 1
A getProperty() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Model;
6
7
use DMK\MKSamlAuth\Exception\PropertyNotFoundException;
8
9
class FrontendUser
10
{
11
    protected $data;
12
13 5
    public function __construct(array $data)
14
    {
15 5
        $this->data = $data;
16 5
    }
17
18 2
    public function getUid()
19
    {
20 2
        return $this->data['uid'];
21
    }
22
23 5
    public function setProperty(string $name, string $value)
24
    {
25 5
        $this->data[$name] = $value;
26 5
    }
27
28 3
    public function hasProperty(string $name)
29
    {
30 3
        return isset($this->data[$name]);
31
    }
32
33 5
    public function getProperty(string $name)
34
    {
35 5
        if (false === \array_key_exists($name, $this->data)) {
36
            throw new PropertyNotFoundException(sprintf('The property "%s" does not exists!', $name));
37
        }
38
39 5
        return $this->data[$name];
40
    }
41
}
42