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.

PostcodeController::fetchAction()   A
last analyzed

Complexity

Conditions 2
Paths 5

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 5
nop 1
1
<?php
2
/*
3
* (c) Wessel Strengholt <[email protected]>
4
*
5
* For the full copyright and license information, please view the LICENSE
6
* file that was distributed with this source code.
7
*/
8
9
namespace Usoft\PostcodeBundle\Controller;
10
11
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12
use Symfony\Component\HttpFoundation\JsonResponse;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * Class PostcodeController
18
 *
19
 * @author Wessel Strengholt <[email protected]>
20
 */
21
class PostcodeController extends Controller
22
{
23
    /**
24
     * @param Request $request
25
     *
26
     * @return JsonResponse
27
     */
28
    public function fetchAction(Request $request)
29
    {
30
        try {
31
            $postcode    = $request->get('postcode');
32
            $houseNumber = $request->get('nummer');
33
34
            $address = $this->get('usoft.postcode.client')->getAddress($postcode, $houseNumber);
35
36
            return new JsonResponse($address->toArray());
37
        } catch (\Exception $exception) {
38
            return new JsonResponse(['message' => $exception->getMessage()], Response::HTTP_SERVICE_UNAVAILABLE);
39
        }
40
    }
41
}
42