ShiftResponder::created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Scheduler\Web\Radar\Responder;
4
5
use Scheduler\Web\Resource\ShiftResource;
6
7
class ShiftResponder extends ResourceResponder
8
{
9
    public function __construct(ShiftResource $resource)
10
    {
11
        $this->resource = $resource;
12
    }
13
14
    protected function created()
15
    {
16
        $shift = $this->payload->getOutput();
17
        $url = "/shifts/{$shift->getId()}";
18
19
        $this->response = $this->response->withStatus(201)
20
                                         ->withHeader("Location", $url);
21
        $this->jsonBody($this->resource->item($shift));
22
    }
23
24
    protected function updated()
25
    {
26
        $this->response = $this->response->withStatus(200);
27
        $output = $this->payload->getOutput();
28
        $this->jsonBody($this->resource->item($output));
29
    }
30
}
31