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 ( 3db8c2...905420 )
by Damian
16:49
created

UploadController::upload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Controller;
4
5
use App\Model\FileCollection;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
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
     *
19
     * @param string|null $name
20
     *
21
     * @return JsonResponse
22
     */
23 3 View Code Duplication
    public function uploadAction($name = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        try {
26 3
            return $this->upload($name);
27 1
        } catch (\Exception $e) {
28 1
            return new JsonResponse([
29 1
                'status'  => 'error',
30 1
                'message' => $e->getMessage(),
31 1
            ]);
32
        }
33
    }
34
35 3
    private function upload($name)
36
    {
37 3
        $this->checkCredentials();
38
39
        /** @var $fileCollection FileCollection */
40 2
        $fileCollection = $this->get('app.file_collection_manager')->getOrCreate($name);
41
42 2
        $newFiles = $this->get('app.upload_manager')->upload(
43
            $fileCollection
44 2
        );
45
46 2
        return new JsonResponse([
47 2
            'status'          => 'ok',
48 2
            'collection_name' => $fileCollection->getName(),
49 2
            'files'           => $newFiles,
50 2
        ]);
51
    }
52
}
53