GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#29)
by Daniel
12:02 queued 09:43
created

GetRouteCandidates::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the prooph/cargo-sample2.
4
 * (c) Alexander Miertsch <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 * 
9
 * Date: 06.12.2015 - 11:23 PM
10
 */
11
namespace Codeliner\CargoBackend\Http\Action;
12
13
use Codeliner\CargoBackend\Application\Booking\BookingService;
14
use Codeliner\CargoBackend\Application\Booking\Dto\RouteCandidateDto;
15
use Codeliner\CargoBackend\Model\Cargo\TrackingId;
16
use Psr\Http\Message\ResponseInterface;
17
use Psr\Http\Message\ServerRequestInterface;
18
use Zend\Diactoros\Response\EmptyResponse;
19
use Zend\Diactoros\Response\JsonResponse;
20
21
/**
22
 * Class GetRouteCandidates
23
 *
24
 * @package Codeliner\CargoBackend\Application\Action
25
 */
26
final class GetRouteCandidates
27
{
28
    /**
29
     * @var BookingService
30
     */
31
    private $bookingService;
32
33
    /**
34
     * GetRouteCandidates constructor.
35
     *
36
     * @param BookingService $bookingService
37
     */
38
    public function __construct(BookingService $bookingService)
39
    {
40
        $this->bookingService = $bookingService;
41
    }
42
43
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        if (null === $trackingId = $request->getAttribute('trackingId')) {
46
            return new EmptyResponse(404);
47
        }
48
49
        $candidateIndex = 1;
50
        return new JsonResponse([
51
            'routeCandidates' => array_map(function(RouteCandidateDto $routeCandidate) use (&$candidateIndex) {
52
                $candidateData = $routeCandidate->getArrayCopy();
53
                $candidateData['id'] = $candidateIndex;
54
                $candidateIndex++;
55
                return $candidateData;
56
            }, $this->bookingService->requestPossibleRoutesForCargo($trackingId))
57
        ]);
58
    }
59
}
60