0 follower

Final Class Yiisoft\Log\Message\ContextValueExtractor

InheritanceYiisoft\Log\Message\ContextValueExtractor

Public Methods

Hide inherited methods

Method Description Defined By
extract() Yiisoft\Log\Message\ContextValueExtractor

Method Details

Hide inherited methods

extract() public static method

public static array extract ( array $context, string $key )
$context array
$key string

                public static function extract(array $context, string $key): array
{
    $path = self::parsePath($key);
    $lastKey = array_pop($path);
    $array = $context;
    foreach ($path as $pathItem) {
        $array = $array[$pathItem] ?? null;
        if (!is_array($array)) {
            return [false, null];
        }
    }
    return array_key_exists($lastKey, $array)
        ? [true, $array[$lastKey]]
        : [false, null];
}