ShiftResponder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A created() 0 9 1
A updated() 0 6 1
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