Layout::jsonSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Slack\MessageBuilder;
12
13
use App\Slack\MessageBuilder\Block\BlockInterface;
14
15
class Layout implements MessageInterface
16
{
17
    /** @var array|BlockInterface[] */
18
    private $blocks;
19
20 3
    public function __construct(BlockInterface ...$blocks)
21
    {
22 3
        $this->blocks = $blocks;
23 3
    }
24
25 3
    public function jsonSerialize(): array
26
    {
27 3
        $jsonData = [];
28
29 3
        foreach ($this->blocks as $block) {
30 3
            $jsonData[] = $block->jsonSerialize();
31
        }
32
33 3
        return ['blocks' => $jsonData];
34
    }
35
}
36