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 ( 23c71a...dcb9a9 )
by Richard
11:04
created

BaseController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 10 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 4
loc 40
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataStore() 0 7 2
A getDisplayOptions() 4 19 4

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
 * Created by PhpStorm.
4
 * User: wechsler
5
 * Date: 29/01/2017
6
 * Time: 12:43
7
 */
8
9
namespace Phase\TakeATicketBundle\Controller;
10
11
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12
use Phase\TakeATicket\DataSource\Factory;
13
14
/**
15
 * @property  \Symfony\Component\DependencyInjection\Container container
16
 */
17
abstract class BaseController extends Controller
18
{
19
    protected $dataSource;
20
21
    /**
22
     * @return \Phase\TakeATicket\DataSource\AbstractSql
23
     */
24
    protected function getDataStore()
25
    {
26
        if (!$this->dataSource) {
27
            $this->dataSource = Factory::datasourceFromDbConnection($this->get('database_connection'));
28
        }
29
        return $this->dataSource;
30
    }
31
32
    /**
33
     * Get display options from config, with overrides if possible
34
     *
35
     * @return array
36
     */
37
    protected function getDisplayOptions()
38
    {
39
        $displayOptions = $this->container->hasParameter('displayOptions') ?
40
            $this->getParameter('displayOptions') : [];
41
42
        // Fixme configure parameter types cleanly
43
        if (strtolower($displayOptions['songInPreview']) === 'false') {
44
            $displayOptions['songInPreview'] = false;
45
        }
46
47 View Code Duplication
        if ($this->isGranted('ROLE_ADMIN')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
48
            $displayOptions['songInPreview'] = true; // force for logged-in users
49
            $displayOptions['isAdmin'] = true; // force for logged-in users
50
        }
51
52
        //        $displayOptions['upcomingCount'] = 3;
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
54
        return $displayOptions;
55
    }
56
}
57