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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 26.19 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 11
loc 42
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A uploadAction() 11 11 2
A upload() 0 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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