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

load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
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