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 ( fe87e3...aa9b3c )
by Damian
16:15
created

UploadController::uploadAction()   B

Complexity

Conditions 2
Paths 5

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 14
nc 5
nop 1
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/{fileCollectionName}", defaults={"fileCollectionName" = null})
17
     * @Method({"POST"})
18
     */
19
    public function uploadAction($fileCollectionName = null)
20
    {
21
        try {
22
            $this->checkCredentials();
23
24
            /** @var $fileCollection FileCollection */
25
            $fileCollection = $this->get('file_collection_manager')->getOrCreate($fileCollectionName);
26
27
            $newFiles = $this->get('upload_manager')->upload(
28
                $fileCollection
29
            );
30
31
            return new JsonResponse(array(
32
                'status' => 'ok',
33
                'collection_name' => $fileCollection->getName(),
34
                'files' => $newFiles
35
            ));
36
        } catch(\Exception $e) {
37
            return new JsonResponse(array(
38
                'status' => 'error',
39
                'message' => $e->getMessage()
40
            ));
41
        }
42
    }
43
44
}
45