Completed
Push — master ( 5c75e0...2a6bdb )
by Pascal
02:56
created

Extensions::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PascalDeVink\CloudEvents;
6
7
use PascalDeVink\CloudEvents\Extension\Extension;
8
use Webmozart\Assert\Assert;
9
10
class Extensions
11
{
12
    /**
13
     * @var array
14
     */
15
    private $listOfExtensions;
16
17 6
    public function __construct(array $listOfExtensions = [])
18
    {
19 6
        Assert::allIsInstanceOf($listOfExtensions, Extension::class);
20
21 3
        $this->listOfExtensions = $listOfExtensions;
22 3
    }
23
24 3
    public function getKeyValuePairs() : array
25
    {
26 3
        return array_merge(
27 3
            ...array_map(
28 1
                   function (Extension $extension) : array {
29 3
                       return $extension->toArray();
30 3
                   },
31 3
                   $this->listOfExtensions
32
               )
33
        );
34
    }
35
}
36