{$currentPath})) { $obj = $obj->{$currentPath}; if(Sanitizer::IsAssoc($obj)) $obj = (object) $obj; }else return $defaultValue; } return $obj; } public static function IsAssoc($arr) { if (!is_array($arr)) return false; if(count(array_keys($arr)) == 0) return false; return array_keys($arr) !== range(0, count($arr) - 1); } public static function PathExist($obj, $path) { if(!is_array($path)) $path = [$path]; if($obj == null) return null; if(is_array($obj)) $obj = (object) $obj; while($currentPath = array_shift($path)) { if(isset($obj->{$currentPath})) { $obj = $obj->{$currentPath}; if(is_array($obj)) $obj = (object) $obj; }else return false; } return true; } public static function SanitizeWebSize($size, $default = '0px') { $size = trim($size); if (preg_match('/^\d+(\.\d+)?(px|%|em)?$/', $size)) { if (!preg_match('/(px|%|em)$/', $size)) { $size .= 'px'; } return $size; } return $default; } }