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