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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 36
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B uploadAction() 0 24 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