| Total Complexity | 6 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 64.29% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | trait HasResponseTrait |
||
| 18 | { |
||
| 19 | use ResponseAwareTrait; |
||
| 20 | |||
| 21 | protected $responseFactory = null; |
||
| 22 | protected $responsePayload = null; |
||
| 23 | |||
| 24 | 1 | /** |
|
| 25 | * @return Response |
||
| 26 | 1 | */ |
|
| 27 | public function newResponse() |
||
| 28 | { |
||
| 29 | return ResponsePayloadTransformer::make($this, $this->payload()); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return null |
||
| 34 | */ |
||
| 35 | protected function getResponseFactory(): ?ResponseFactory |
||
| 36 | { |
||
| 37 | if ($this->responseFactory === null) { |
||
| 38 | $this->responseFactory = new ResponseFactory(); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $this->responseFactory; |
||
| 42 | } |
||
| 43 | |||
| 44 | 1 | /** |
|
| 45 | * @return null |
||
| 46 | 1 | */ |
|
| 47 | 1 | public function payload() |
|
| 48 | { |
||
| 49 | if ($this->responsePayload === null) { |
||
| 50 | 1 | $this->responsePayload = $this->generateResponsePayload(); |
|
| 51 | } |
||
| 52 | |||
| 53 | return $this->responsePayload; |
||
| 54 | } |
||
| 55 | |||
| 56 | 1 | /** |
|
| 57 | * @return ResponsePayload |
||
| 58 | 1 | */ |
|
| 59 | 1 | protected function generateResponsePayload(): ResponsePayload |
|
| 62 | 1 | } |
|
| 63 | } |
||
| 64 |