Beispiel #1
0
 public function it_can_get_default_output()
 {
     $error = new Error('title', 'code');
     $error->setDetail('some detail');
     $error->setId('yolol');
     $this->beConstructedWith($error);
     $object = new \stdClass();
     $object->title = 'title';
     $object->code = 'code';
     $object->detail = 'some detail';
     $object->id = 'yolol';
     $this->getOutput()->shouldObjectMatch($object);
 }
Beispiel #2
0
 /**
  * @return object
  */
 public function getOutput()
 {
     $error = ['title' => $this->resource->getTitle(), 'code' => $this->resource->getCode()];
     if ($this->resource->getDetail()) {
         $error['detail'] = $this->resource->getDetail();
     }
     if ($this->resource->getId()) {
         $error['id'] = $this->resource->getId();
     }
     if ($this->resource->getLinks()->hasLinks()) {
         $error['links'] = $this->resource->getLinks()->getSerializer()->getOutput();
     }
     return (object) $error;
 }