Advertisement
danlchenkoandrew

Untitled

Jan 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. class ErrorResponsePart implements ResponsePartInterface
  2. {
  3.    /**
  4.     * Specification.
  5.     *
  6.     * @var SpecificationInterface $specification
  7.     */
  8.    private $specification;
  9.  
  10.    /**
  11.     * Response part data.
  12.     *
  13.     * @var ResponseDtoInterface $partData
  14.     */
  15.    private $partData;
  16.  
  17.    /**
  18.     * Formatter context.
  19.     *
  20.     * @var FormatterContext $formatterContext
  21.     */
  22.    private $formatterContext;
  23.  
  24.    /**
  25.     * ErrorResponsePart constructor.
  26.     *
  27.     * @param SpecificationInterface $specification
  28.     * @param FormatterContext $formatterContext
  29.     */
  30.    public function __construct(SpecificationInterface $specification, FormatterContext $formatterContext)
  31.    {
  32.        $this->specification = $specification;
  33.        $this->formatterContext = $formatterContext;
  34.    }
  35.  
  36.    /**
  37.     * {@inheritdoc}
  38.     */
  39.    public function addData(ResponseDtoInterface $data) : void
  40.    {
  41.        if ($this->specification->isSatisfiedBy($data)) {
  42.            $this->partData = $this->formatterContext->process($data);
  43.        }
  44.    }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement