1 | <?php |
||
19 | class ObjectHelper |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Configures an object with the initial property values. |
||
24 | * |
||
25 | * @param BaseObject $object |
||
26 | * @param array $properties |
||
27 | * @return BaseObject |
||
28 | */ |
||
29 | public static function populate(BaseObject $object, $properties = []): BaseObject |
||
41 | |||
42 | /** |
||
43 | * Create a new object |
||
44 | * |
||
45 | * @param $config |
||
46 | * @param string|null $instanceOf |
||
47 | * @throws InvalidConfigException |
||
48 | * @return BaseObject |
||
49 | */ |
||
50 | public static function create($config, string $instanceOf = null): BaseObject |
||
66 | |||
67 | /** |
||
68 | * Checks the config for a valid class |
||
69 | * |
||
70 | * @param $config |
||
71 | * @param string|null $instanceOf |
||
72 | * @param bool $removeClass |
||
73 | * @throws InvalidConfigException |
||
74 | * @return string |
||
75 | */ |
||
76 | public static function checkConfig(&$config, string $instanceOf = null, bool $removeClass = true): string |
||
95 | |||
96 | /** |
||
97 | * Get a class from a config |
||
98 | * |
||
99 | * @param $config |
||
100 | * @param bool $removeClass |
||
101 | * @throws InvalidConfigException |
||
102 | * @return string |
||
103 | */ |
||
104 | public static function getClassFromConfig(&$config, bool $removeClass = false): string |
||
121 | |||
122 | /** |
||
123 | * Find a class from a config |
||
124 | * |
||
125 | * @param $config |
||
126 | * @param bool $removeClass |
||
127 | * @return null|string |
||
128 | */ |
||
129 | public static function findClassFromConfig(&$config, bool $removeClass = false) |
||
162 | } |
||
163 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: