Completed
Push — staging ( 5f9089...8e7d49 )
by Matthew
04:33
created

AlertEndpointController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getSingle() 0 10 2
1
<?php
2
3
namespace Ps2alerts\Api\Controller\Endpoint;
4
5
use League\Fractal\Manager;
6
use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController;
7
use Ps2alerts\Api\Repository\AlertRepository;
8
use Ps2alerts\Api\Transformer\AlertTransformer;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
12
class AlertEndpointController extends AbstractEndpointController
13
{
14
    public function __construct(
15
        AlertRepository  $repository,
16
        AlertTransformer $transformer,
17
        Manager          $fractal
18
    ) {
19
        $this->repository  = $repository;
20
        $this->transformer = $transformer;
21
        $this->fractal     = $fractal;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fractal of type object<League\Fractal\Manager> is incompatible with the declared type object<League\Fractal> of property $fractal.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
22
    }
23
24
    /**
25
     * Returns a single alert's information
26
     *
27
     * @see AbstractEndpointController::respondWithItem
28
     *
29
     * @param  Symfony\Component\HttpFoundation\Request  $request
30
     * @param  Symfony\Component\HttpFoundation\Response $response
31
     * @param  array
32
     *
33
     * @return array
34
     */
35
    public function getSingle(Request $request, Response $response, array $args)
36
    {
37
        $alert = $this->repository->readSingle($args['id']);
38
39
        if (empty($alert)) {
40
            return $this->errorEmpty($response);
41
        }
42
43
        return $this->respond('item', $alert, $this->transformer, $request, $response);
44
    }
45
}
46