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

BlockUnserializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 6 1
A __construct() 0 3 1
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
}