forked from gesdinet/MetronicDatatableBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueObject.php
More file actions
58 lines (52 loc) · 1.39 KB
/
ValueObject.php
File metadata and controls
58 lines (52 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* This file is part of the Gesdinet MetronicDataTableBundle package.
*
* (c) Gesdinet <marcos@gesdinet.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gesdinet\MetronicDataTableBundle;
/**
* Immutable value object.
*/
class ValueObject
{
/**
* Checks whether specified property exists.
*
* @param string $name name of the property
*
* @return bool TRUE if the property exists, FALSE otherwise
*/
public function __isset(string $name): bool
{
return property_exists($this, $name);
}
/**
* Returns current value of specified property.
*
* @param string $name name of the property
*
* @throws \BadMethodCallException if the property doesn't exist
*
* @return mixed current value of the property
*/
public function __get(string $name)
{
if (!property_exists($this, $name)) {
throw new \BadMethodCallException(sprintf('Unknown property "%s" in class "%s".', $name, static::class));
}
return $this->$name;
}
/**
* Prevents object's properties from modification.
*
* @param string $name name of the property
* @param mixed $value new value of the property
*/
final public function __set(string $name, mixed $value)
{
}
}