public static function fromArray()

in src/Context.php [78:93]


    public static function fromArray(array $arr)
    {
        // When "resource" is defined in the root (instead of in "context") it
        // is a string representing the resource name
        if (isset($arr['resource']) && is_string($arr['resource'])) {
            $arr['resource'] = ['name' => $arr['resource']];
        }

        $args = [];
        $argKeys = ['eventId', 'timestamp', 'eventType', 'resource', 'domain'];
        foreach ($argKeys as $key) {
            $args[] = $arr[$key] ?? null;
        }

        return new static(...$args);
    }