AbstractType::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CyberLine\SystemdState\Types;
4
5
abstract class AbstractType implements TypesInterface, \JsonSerializable
6
{
7
    /** @var \DateTimeImmutable */
8
    protected $ActiveEnterTimestamp;
9
10
    /** @var integer */
11
    protected $ActiveEnterTimestampMonotonic;
12
13
    /** @var integer */
14
    protected $ActiveExitTimestampMonotonic;
15
16
    /** @var string */
17
    protected $ActiveState;
18
19
    /** @var boolean */
20
    protected $AllowIsolate;
21
22
    /** @var boolean */
23
    protected $AssertResult;
24
25
    /** @var \DateTimeImmutable */
26
    protected $AssertTimestamp;
27
28
    /** @var integer */
29
    protected $AssertTimestampMonotonic;
30
31
    /** @var array */
32
    protected $Before = [];
33
34
    /** @var boolean */
35
    protected $CanIsolate;
36
37
    /** @var boolean */
38
    protected $CanReload;
39
40
    /** @var boolean */
41
    protected $CanStart;
42
43
    /** @var boolean */
44
    protected $CanStop;
45
46
    /** @var boolean */
47
    protected $ConditionResult;
48
49
    /** @var \DateTimeImmutable */
50
    protected $ConditionTimestamp;
51
52
    /** @var integer */
53
    protected $ConditionTimestampMonotonic;
54
55
    /** @var boolean */
56
    protected $DefaultDependencies;
57
58
    /** @var string */
59
    protected $Description;
60
61
    /** @var string */
62
    protected $Id;
63
64
    /** @var boolean */
65
    protected $IgnoreOnIsolate;
66
67
    /** @var integer */
68
    protected $InactiveEnterTimestampMonotonic;
69
70
    /** @var \DateTimeImmutable */
71
    protected $InactiveExitTimestamp;
72
73
    /** @var integer */
74
    protected $InactiveExitTimestampMonotonic;
75
76
    /** @var string */
77
    protected $InvocationID;
78
79
    /** @var string */
80
    protected $JobTimeoutAction;
81
82
    /** @var string */
83
    protected $JobTimeoutUSec;
84
85
    /** @var string */
86
    protected $LoadError;
87
88
    /** @var string */
89
    protected $LoadState;
90
91
    /** @var array */
92
    protected $Names = [];
93
94
    /** @var boolean */
95
    protected $NeedDaemonReload;
96
97
    /** @var string */
98
    protected $OnFailureJobMode;
99
100
    /** @var boolean */
101
    protected $Perpetual;
102
103
    /** @var boolean */
104
    protected $RefuseManualStart;
105
106
    /** @var boolean */
107
    protected $RefuseManualStop;
108
109
    /** @var string */
110
    protected $StartLimitAction;
111
112
    /** @var boolean */
113
    protected $StartLimitBurst;
114
115
    /** @var integer */
116
    protected $StartLimitInterval;
117
118
    /** @var integer */
119
    protected $StartLimitIntervalSec;
120
121
    /** @var \DateTimeImmutable */
122
    protected $StateChangeTimestamp;
123
124
    /** @var integer */
125
    protected $StateChangeTimestampMonotonic;
126
127
    /** @var boolean */
128
    protected $StopWhenUnneeded;
129
130
    /** @var string */
131
    protected $SubState;
132
133
    /** @var boolean */
134
    protected $Transient;
135
136
    /**
137
     * @param $name
138
     * @param $value
139
     * @return $this
140
     */
141
    public function __call($name, $value)
142
    {
143
        $action = substr($name, 0, 3);
144
        $property = substr($name, 3);
145
146
        if (!property_exists($this, $property)) {
147
            throw new \RuntimeException(
148
                sprintf(
149
                    'Property `%s` is not known to me. Please fill a Bug report!' . PHP_EOL . 'Info: `%s`',
150
                    $property,
151
                    implode(' ', $value)
152
                )
153
            );
154
        }
155
156
        if ($action === 'set') {
157
            $this->{$property} = $value[0];
158
159
            return $this;
160
        }
161
162
        if ($action === 'get') {
163
            return $this->{$property};
164
        }
165
166
        throw new \InvalidArgumentException('invalid call to ' . __METHOD__);
167
    }
168
169
    public function getId(): string
170
    {
171
        return $this->Id;
172
    }
173
174
    public function jsonSerialize()
175
    {
176
        return get_object_vars($this);
177
    }
178
}
179