method makeReadable documentation in bbn\Str
Returns the argumented value, replacing not standard objects (not stdClass) by their class name.
Example
$myObj = new stdClass();
$myObj->myProp1 = 23;
$myObj->myProp2 = "world";
$myObj->myProp3 = [1, 5, 6];
$user = \bbn\User::getInstance();
$myArray = [
'user' => $user,
'obj' => $myObj,
'val' => 23,
'text' => "Hello!"
];
X::hdump(\bbn\Str::makeReadable($user));
// (string) "appui/user"
X::hdump(\bbn\Str::makeReadable($myArray));
/* (array)
[
"user" => "appui\\user",
"obj" => [
"myProp1" => 23,
"myProp2" => "world",
"myProp3" => [1, 5, 6,],
],
"val" => 23,
"text" => "Hello!",
]
function($o)
{
$is_array = false;
if (\is_object($o)) {
$class = \get_class($o);
if ($class === 'stdClass') {
$is_array = 1;
}
else{
return $class;
}
}
if (\is_array($o) || $is_array) {
$r = [];
foreach ($o as $k => $v){
$r[$k] = self::makeReadable($v);
}
return $r;
}
return $o;
}
Returns the argumented value, replacing not standard objects (not stdClass) by their class name. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions