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

Extensions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKeyValuePairs() 0 8 1
A __construct() 0 5 1
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