Passed
Push — master ( 6c23d7...d63c7e )
by Florent
01:40
created

AuthenticationExtensionsClientOutputsLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace U2FAuthentication\Fido2\AuthenticationExtensions;
15
16
use Assert\Assertion;
17
use CBOR\CBORObject;
18
use CBOR\MapObject;
19
20
class AuthenticationExtensionsClientOutputsLoader
21
{
22
    public static function load(CBORObject $object): AuthenticationExtensionsClientOutputs
23
    {
24
        Assertion::isInstanceOf($object, MapObject::class, 'Invalid extension object');
25
        $data = $object->getNormalizedData();
26
        $extensions = new AuthenticationExtensionsClientOutputs();
27
        foreach ($data as $key => $value) {
28
            Assertion::string($key, 'Invalid extension key');
29
            $extensions->add(new AuthenticationExtension($key, $value));
30
        }
31
32
        return $extensions;
33
    }
34
}
35