Advertisement
danlchenkoandrew

Untitled

Jan 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. class ErrorResponsePart implements ResponsePartInterface
  2. {
  3.    /**
  4.     * Error response part data.
  5.     *
  6.     * @var ResponseDtoInterface $partData
  7.     */
  8.    private $partData;
  9.  
  10.    /**
  11.     * {@inheritdoc}
  12.     */
  13.    public function addData(ResponseDtoInterface $data) : void
  14.    {
  15.        if ($data instanceof ErrorDtoInterface) {
  16.            $this->partData = $this->format($data);
  17.        }
  18.    }
  19.  
  20.    /**
  21.     * Prepares response data.
  22.     *
  23.     * @param ResponseDtoInterface $data
  24.     */
  25.    public function format(ResponseDtoInterface $data) : void
  26.    {
  27.         if ($data instanceof ListDataDtoInterface) {
  28.             $formatted = $data->getListData();
  29.         } elseif (/* some expressions */) {
  30.             // some logic
  31.         } elseif (/* some expressions */) {
  32.             // some logic
  33.         }
  34.  
  35.        return $formatted ?? $data;
  36.    }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement