AttributeExtractor::extractAttributes()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 11.1035

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 7
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 13
ccs 3
cts 8
cp 0.375
crap 11.1035
rs 9.6111
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