Passed
Pull Request — master (#1412)
by Marcin
02:24
created

LazyObject   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace JMS\Serializer;
4
5
class LazyObject implements \JsonSerializable
6
{
7
    /**
8
     * @var callable
9
     */
10
    private $serialisation;
11
    private $params;
12
13
14
    public function __construct(callable $serialisation, ...$params)
15
    {
16
        $this->serialisation = $serialisation;
17
        $this->params = $params;
18
    }
19
20
    public function jsonSerialize()
21
    {
22
        $callback = $this->serialisation;
23
        return $callback(...$this->params);
24
    }
25
}