CallableItem::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Borodulin\Container\Autowire\Item;
6
7
use Borodulin\Container\Autowire\AutowireItemInterface;
8
9
class CallableItem implements AutowireItemInterface
10
{
11
    /**
12
     * @var callable
13
     */
14
    private $callable;
15
    /**
16
     * @var array
17
     */
18
    private $args;
19
20 3
    public function __construct(callable $callable, array $args)
21
    {
22 3
        $this->callable = $callable;
23 3
        $this->args = $args;
24 3
    }
25
26 1
    public function serialize(): string
27
    {
28 1
        return serialize([\Opis\Closure\serialize($this->callable), $this->args]);
29
    }
30
31
    /**
32
     * @param string $serialized
33
     */
34 1
    public function unserialize($serialized): void
35
    {
36 1
        [$this->callable, $this->args] = unserialize($serialized);
37 1
        $this->callable = \Opis\Closure\unserialize($this->callable);
38 1
    }
39
40 2
    public function getCallable(): callable
41
    {
42 2
        return $this->callable;
43
    }
44
45 2
    public function getArgs(): array
46
    {
47 2
        return $this->args;
48
    }
49
}
50