|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//---------------------------------------------------------------------- |
|
4
|
|
|
// |
|
5
|
|
|
// Copyright (C) 2015-2019 Artem Rodygin |
|
6
|
|
|
// |
|
7
|
|
|
// This file is part of DataTables Symfony bundle. |
|
8
|
|
|
// |
|
9
|
|
|
// You should have received a copy of the MIT License along with |
|
10
|
|
|
// the bundle. If not, see <http://opensource.org/licenses/MIT>. |
|
11
|
|
|
// |
|
12
|
|
|
//---------------------------------------------------------------------- |
|
13
|
|
|
|
|
14
|
|
|
namespace DataTables; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Immutable value object. |
|
18
|
|
|
*/ |
|
19
|
|
|
class ValueObject |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Checks whether specified property exists. |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $name Name of the property. |
|
25
|
|
|
* |
|
26
|
|
|
* @return bool TRUE if the property exists, FALSE otherwise. |
|
27
|
|
|
*/ |
|
28
|
1 |
|
public function __isset(string $name): bool |
|
29
|
|
|
{ |
|
30
|
1 |
|
return property_exists($this, $name); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Returns current value of specified property. |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $name Name of the property. |
|
37
|
|
|
* |
|
38
|
|
|
* @throws \BadMethodCallException If the property doesn't exist. |
|
39
|
|
|
* |
|
40
|
|
|
* @return mixed Current value of the property. |
|
41
|
|
|
*/ |
|
42
|
2 |
|
public function __get(string $name) |
|
43
|
|
|
{ |
|
44
|
2 |
|
if (!property_exists($this, $name)) { |
|
45
|
1 |
|
throw new \BadMethodCallException(sprintf('Unknown property "%s" in class "%s".', $name, get_class($this))); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
return $this->{$name}; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Prevents object's properties from modification. |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $name Name of the property. |
|
55
|
|
|
* @param mixed $value New value of the property. |
|
56
|
|
|
*/ |
|
57
|
1 |
|
final public function __set(string $name, $value) |
|
58
|
|
|
{ |
|
59
|
1 |
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|