public static function getPropertyForKeyOrDefault(&$data, string $property, $default, bool $ignoreCase = false, bool $deepSearchDotNotation = false)
    {
        $keyToCheck = $property;
        $objectToCheck = &$data;
        
        if ($ignoreCase) {
            $keyToCheck = strtolower($keyToCheck);
            $objectToCheck = ObjectUtils::changeKeyCase($objectToCheck);
        }
        
        if (property_exists($objectToCheck, $keyToCheck)) {
            return $objectToCheck->$keyToCheck;
        }
        
        if (!$deepSearchDotNotation || strpos($keyToCheck, ".") === false) {
            return $default;
        }
        
        $keySeparated = explode('.', $keyToCheck);
        $checkOrReturn = &$objectToCheck;
        
        foreach ($keySeparated as $keyPart) {
            if (is_array($data)) {
                $checkOrReturn = ArrayUtils::getArrayValueForKeyOrDefault($checkOrReturn, $keyPart, $default);
                continue;
            }
            
            if (!is_object($checkOrReturn) || !property_exists($checkOrReturn, $keyPart)) {
                $checkOrReturn = &$default;
                break;
            }
            
            $checkOrReturn = &$checkOrReturn->$keyPart;
        }
        
        return $checkOrReturn;
    }
public static function getPropertyForKeyOrDefault(&$data, string $property, $default, bool $ignoreCase = false, bool $deepSearchDotNotation = false)
    {
        $keyToCheck = $property;
        $objectToCheck = &$data;
        
        if ($ignoreCase) {
            $keyToCheck = strtolower($keyToCheck);
            $objectToCheck = ObjectUtils::changeKeyCase($objectToCheck);
        }
        
        if (property_exists($objectToCheck, $keyToCheck)) {
            return $objectToCheck->$keyToCheck;
        }
        
        if (!$deepSearchDotNotation || strpos($keyToCheck, ".") === false) {
            return $default;
        }
        
        $keySeparated = explode('.', $keyToCheck);
        $checkOrReturn = &$objectToCheck;
        
        foreach ($keySeparated as $keyPart) {
            if (is_array($data)) {
                $checkOrReturn = ArrayUtils::getArrayValueForKeyOrDefault($checkOrReturn, $keyPart, $default);
                continue;
            }
            
            if (!is_object($checkOrReturn) || !property_exists($checkOrReturn, $keyPart)) {
                $checkOrReturn = &$default;
                break;
            }
            
            $checkOrReturn = &$checkOrReturn->$keyPart;
        }
        
        return $checkOrReturn;
    }
public static function getPropertyForKeyOrDefault ( & $ data , string $ property , $ default , bool $ ignoreCase = false , bool $ deepSearchDotNotation = false ) { $ keyToCheck = $ property ; $ objectToCheck = & $ data ; if ( $ ignoreCase ) { $ keyToCheck = strtolower ( $ keyToCheck ) ; $ objectToCheck = ObjectUtils :: changeKeyCase ( $ objectToCheck ) ; } if ( property_exists ( $ objectToCheck , $ keyToCheck ) ) { return $ objectToCheck -> $ keyToCheck ; } if ( ! $ deepSearchDotNotation || strpos ( $ keyToCheck , "." ) === false ) { return $ default ; } $ keySeparated = explode ( '.' , $ keyToCheck ) ; $ checkOrReturn = & $ objectToCheck ; foreach ( $ keySeparated as $ keyPart ) { if ( is_array ( $ data ) ) { $ checkOrReturn = ArrayUtils :: getArrayValueForKeyOrDefault ( $ checkOrReturn , $ keyPart , $ default ) ; continue ; } if ( ! is_object ( $ checkOrReturn ) || ! property_exists ( $ checkOrReturn , $ keyPart ) ) { $ checkOrReturn = & $ default ; break ; } $ checkOrReturn = & $ checkOrReturn -> $ keyPart ; } return $ checkOrReturn ; }
Get the value from an object of the given property.
Return a default value if the property could not be found.

@param object $data
The object to get the value from.

@param string $property
The property to get the value for.

@param mixed $default
Value to return if the key is not found in the array.

@param bool $ignoreCase
[optional]
Whether to treat lowercase and uppercase letters as equivalent during the search.

@param bool $deepSearchDotNotation
[optional]
Use $key as a detailed path specifier with path elements separated by a dot.
E.g: path.to.value will try to find $array['path']['to']['value'] in addition to $array['path.to.value'].

@return mixed
Get the value from an object of the given property . Return a default value if the property could not be found .