Changes::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 8
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\EntityState;
5
6
/**
7
 * Changes.
8
 *
9
 * @author Stratadox
10
 */
11
final class Changes implements TellsWhatChanged
12
{
13
    private $added;
14
    private $altered;
15
    private $removed;
16
17
    private function __construct(
18
        ListsEntityStates $added,
19
        ListsEntityStates $altered,
20
        ListsEntityStates $removed
21
    ) {
22
        $this->added = $added;
23
        $this->altered = $altered;
24
        $this->removed = $removed;
25
    }
26
27
    /**
28
     * Produces a container of changed state.
29
     *
30
     * @param ListsEntityStates $added   The added entities.
31
     * @param ListsEntityStates $altered The altered entities.
32
     * @param ListsEntityStates $removed The removed entities.
33
     * @return TellsWhatChanged          The container with changes.
34
     */
35
    public static function wereMade(
36
        ListsEntityStates $added,
37
        ListsEntityStates $altered,
38
        ListsEntityStates $removed
39
    ): TellsWhatChanged {
40
        return new self($added, $altered, $removed);
41
    }
42
43
    /** @inheritdoc */
44
    public function added(): ListsEntityStates
45
    {
46
        return $this->added;
47
    }
48
49
    /** @inheritdoc */
50
    public function altered(): ListsEntityStates
51
    {
52
        return $this->altered;
53
    }
54
55
    /** @inheritdoc */
56
    public function removed(): ListsEntityStates
57
    {
58
        return $this->removed;
59
    }
60
}
61