Completed
Pull Request — master (#3)
by David
04:28 queued 01:58
created

BlockUnserializer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\CMS\Serializer;
5
6
use TheCodingMachine\CMS\Block\Block;
7
8
/**
9
 * Class in charge of creating a block from a JSON message.
10
 */
11
class BlockUnserializer
12
{
13
    /**
14
     * @var ThemeUnserializerInterface
15
     */
16
    private $themeUnserializer;
17
18
    public function __construct(ThemeUnserializerInterface $themeUnserializer)
19
    {
20
        $this->themeUnserializer = $themeUnserializer;
21
    }
22
23
    /**
24
     * @param mixed[] $arr
25
     * @return Block
26
     */
27
    public function createFromArray(array $arr): Block
28
    {
29
        $context = $arr['context'];
30
        $themeDescriptor = $this->themeUnserializer->createFromArray($arr['theme']);
31
32
        return new Block($themeDescriptor, $context);
33
    }
34
35
}