Add test for service option exporter
This commit is contained in:
parent
d95a63c09b
commit
609bf32843
4 changed files with 154 additions and 0 deletions
|
@ -43,3 +43,31 @@ if (! function_exists('is_digit')) {
|
|||
return is_bool($value) ? false : ctype_digit(strval($value));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('object_get_strict')) {
|
||||
/**
|
||||
* Get an object using dot notation. An object key with a value of null is still considered valid
|
||||
* and will not trigger the response of a default value (unlike object_get).
|
||||
*
|
||||
* @param object $object
|
||||
* @param string $key
|
||||
* @param null $default
|
||||
* @return mixed
|
||||
*/
|
||||
function object_get_strict($object, $key, $default = null)
|
||||
{
|
||||
if (is_null($key) || trim($key) == '') {
|
||||
return $object;
|
||||
}
|
||||
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (! is_object($object) || ! property_exists($object, $segment)) {
|
||||
return value($default);
|
||||
}
|
||||
|
||||
$object = $object->{$segment};
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue