Completed
Push — master ( 25f365...554d02 )
by Alexey
02:46
created

Branch::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Reflection\Tests\Dummy;
6
7
use \JsonSerializable as Serializable;
8
use \Reflection\Tests\Dummy\Leaf as LeafClass;
9
10
/**
11
 * Class Branch
12
 * @package Reflection\Tests\Dummy
13
 */
14
class Branch implements Serializable {
15
16
    /**
17
     * @var double
18
     */
19
    private $length;
20
21
    /**
22
     * @var LeafClass[]
23
     */
24
    private $leaves;
25
26
    /**
27
     * @return float
28
     */
29
    public function getLength(): float {
30
        return $this->length;
31
    }
32
33
    /**
34
     * @param float $length
35
     * @return Branch
36
     */
37
    public function setLength(float $length): Branch {
38
        $this->length = $length;
39
40
        return $this;
41
    }
42
43
    /**
44
     * @return LeafClass[]
45
     */
46
    public function getLeaves(): array {
47
        return $this->leaves;
48
    }
49
50
    /**
51
     * @param LeafClass[] $leaves
52
     * @return Branch
53
     */
54
    public function setLeaves(array $leaves = []): Branch {
55
        $this->leaves = $leaves;
56
57
        return $this;
58
    }
59
60
    /**
61
     * @param float $length
62
     * @param LeafClass[] $leaves
63
     */
64
    public function __construct(float $length = null, array $leaves = []) {
65
        $this->length = $length;
66
        $this->leaves = $leaves;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function jsonSerialize(): array {
73
        return [
74
            'length' => $this->getLength(),
75
            'leaves' => $this->getLeaves()
76
        ];
77
    }
78
79
}