Advertisement
danlchenkoandrew

Untitled

Jan 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. class ListDataFormatter implements FormatterInterface
  2. {
  3.    /**
  4.     * Checks object for needed requirements.
  5.     *
  6.     * @var FormatterSpecificationInterface $specification
  7.     */
  8.    private $specification;
  9.  
  10.    /**
  11.     * ListDataFormatter constructor.
  12.     *
  13.     * @param FormatterSpecificationInterface $specification
  14.     */
  15.    public function __construct(FormatterSpecificationInterface $specification)
  16.    {
  17.        $this->specification = $specification;
  18.    }
  19.  
  20.   /**
  21.    * {@inheritdoc}
  22.    */
  23.   public function format(ResponseDtoInterface $data)
  24.    {
  25.        if ($this->specification->isSatisfiedBy($data)) {
  26.            $data = $data->getData();
  27.        }
  28.  
  29.        return $data;
  30.    }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement