AttributeExtractor   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 19
ccs 3
cts 10
cp 0.3
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extractAttributes() 0 13 5
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth;
6
7
use LightSaml\Model\Protocol\Response;
8
9
final class AttributeExtractor
10
{
11
    private function __construct()
12
    {
13
    }
14
15 1
    public static function extractAttributes(Response $response)
16
    {
17 1
        foreach ($response->getAllAssertions() as $assertion) {
18
            foreach ($assertion->getAllAttributeStatements() as $statement) {
19
                foreach ($statement->getAllAttributes() as $attribute) {
20
                    yield $attribute->getName() => \count($attribute->getAllAttributeValues()) > 1
21
                        ? $attribute->getAllAttributeValues()
22
                        : $attribute->getFirstAttributeValue();
23
                }
24
            }
25
        }
26
27 1
        yield from [];
28 1
    }
29
}
30