Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 681 Bytes

DenormalizerContextBuilder.md

File metadata and controls

30 lines (22 loc) · 681 Bytes

DenormalizerContextBuilder

<?php

use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextBuilder;
use Psr\Http\Message\ServerRequestInterface;

/** @var ServerRequestInterface $request */
$request = ...;

$context = DenormalizerContextBuilder::create()
    ->setRequest($request)
    ->setAttributes(['key' => 'value'])
    ->setAllowedAdditionalFields(['allowed_additional_field'])
    ->setClearMissing(true)
    ->getContext();

echo $context->getAllowedAdditionalFields();
// ['allowed_additional_field']

$context->getRequest();
// instanceof ServerRequestInterface

echo $context->isClearMissing();
// true

echo $context->getAttributes('key');
// value