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
Push — master ( cba8be...4721cc )
by Damian
02:31
created

UploadController::uploadAction()   B

Complexity

Conditions 2
Paths 5

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 14
cts 14
cp 1
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 14
nc 5
nop 1
crap 2
1
<?php
2
3
namespace App\Controller;
4
5
use App\Model\FileCollection;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Symfony\Component\HttpFoundation\JsonResponse;
10
11
class UploadController extends Controller
12
{
13
    use CredentialsCheckTrait;
14
15
    /**
16
     * @Route("/api/upload/{name}", defaults={"name" = null}, requirements={"name" = "^[a-f0-9]{32}$"})
17
     * @Method({"POST"})
18
     * @param string|null $name
19
     * @return JsonResponse
20
     */
21 3
    public function uploadAction($name = null)
22
    {
23
        try {
24 3
            $this->checkCredentials();
25
26
            /** @var $fileCollection FileCollection */
27 2
            $fileCollection = $this->get('file_collection_manager')->getOrCreate($name);
28
29 2
            $newFiles = $this->get('upload_manager')->upload(
30
                $fileCollection
31 2
            );
32
33 2
            return new JsonResponse(array(
34 2
                'status' => 'ok',
35 2
                'collection_name' => $fileCollection->getName(),
36
                'files' => $newFiles
37 2
            ));
38 1
        } catch (\Exception $e) {
39 1
            return new JsonResponse(array(
40 1
                'status' => 'error',
41 1
                'message' => $e->getMessage()
42 1
            ));
43
        }
44
    }
45
46
}
47