SecurityRequirement   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 10
c 2
b 1
f 1
dl 0
loc 26
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toNative() 0 3 1
A __construct() 0 9 3
A fromNative() 0 3 1
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