SecurityRequirement::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 3
eloc 6
c 2
b 1
f 1
nc 3
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
4
namespace Apie\OpenapiSchema\Spec;
5
6
use Apie\ValueObjects\ValueObjectInterface;
7
8
/**
9
 * @see https://swagger.io/specification/#security-requirement-object
10
 */
11
class SecurityRequirement implements ValueObjectInterface
12
{
13
    /**
14
     * @var string[][]
15
     */
16
    private $securityRequirementArray;
17
18
    public static function fromNative($value)
19
    {
20
        return new SecurityRequirement($value);
21
    }
22
23
    public function toNative()
24
    {
25
        return $this->securityRequirementArray;
26
    }
27
28
    public function __construct(iterable $value)
29
    {
30
        $this->securityRequirementArray = [];
31
        foreach ($value as $name => $securityRequirements) {
32
            $list = [];
33
            foreach ($securityRequirements as $securityRequirement) {
34
                $list[] = (string) $securityRequirement;
35
            }
36
            $this->securityRequirementArray[$name] = $list;
37
        }
38
    }
39
}
40