public static function deserializeOutputHeaders()

in src/Deserializer.php [210:258]


    public static function deserializeOutputHeaders(ResultModel $result, OperationOutput $output)
    {
        $headers = $output->getHeaders();
        if (empty($headers)) {
            return;
        }

        $usermetas = [];
        $ro = new \ReflectionObject($result);
        foreach ($ro->getProperties() as $property) {
            $annotation = Functions::getHeaderAnnotation($property);
            if ($annotation == null) {
                continue;
            }

            #usermeta
            if ($annotation->format === 'usermeta') {
                \array_push($usermetas, ['property' => $property, 'annotation' => $annotation]);
                continue;
            }

            $name = $annotation->rename;
            if (!\array_key_exists($name, $headers)) {
                continue;
            }

            $value = self::castToAny( $headers[$name], $annotation->type, $annotation->format);
            $property->setAccessible(true);
            $property->setValue($result, $value);
        }

        foreach ($usermetas as $item) {
            $annotation = $item['annotation'];
            $property = $item['property'];
            $prefix = strtolower($annotation->rename);
            $len = strlen($prefix);
            $meta = []; 
            foreach ($headers as  $key => $value) {
                if (strncasecmp($key, $prefix, $len) == 0) {
                    $meta[strtolower(substr($key, $len))] = $value;
                }
            }

            if (count($meta) > 0) {
                $property->setAccessible(true);
                $property->setValue($result, $meta);
            }
        }
    }