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.
Passed
Push — master ( 6812c5...04c9e1 )
by Richard
02:58
created

BaseController::defaultViewParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
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 Phase\TakeATicket\DataSource\AbstractSql;
12
use Phase\TakeATicket\Model\Platform;
13
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
14
use Phase\TakeATicket\DataSource\Factory;
15
16
/**
17
 * @property  \Symfony\Component\DependencyInjection\Container container
18
 */
19
abstract class BaseController extends Controller
20
{
21
    /**
22
     * Use getDataStore() rather than accessing directly as this may not be populated
23
     *
24
     * @var AbstractSql
25
     */
26
    protected $dataSource;
27
28
    /**
29
     * @return AbstractSql
30
     */
31
    protected function getDataStore()
32
    {
33
        if (!$this->dataSource) {
34
            $this->dataSource = Factory::datasourceFromDbConnection($this->get('database_connection'));
35
            $this->dataSource->setUpcomingCount($this->getUpcomingCount()); // FIXME reduce navel-gazing
36
        }
37
        return $this->dataSource;
38
    }
39
40
    /**
41
     * Get display options from config, with overrides if possible
42
     *
43
     * @return array
44
     */
45
    protected function getDisplayOptions()
46
    {
47
        $displayOptions = $this->container->hasParameter('displayOptions') ?
48
            $this->getParameter('displayOptions') : [];
49
50
        $displayOptions['upcomingCount'] = $this->getUpcomingCount();
51
        $displayOptions['songInPreview'] = (bool)$this->getDataStore()->fetchSetting('songInPreview');
52
53
        if ($this->isGranted('ROLE_ADMIN')) {
54
            $displayOptions['songInPreview'] = true; // force for logged-in users
55
            $displayOptions['isAdmin'] = true; // force for logged-in users
56
        }
57
58
        return $displayOptions;
59
    }
60
61
    /**
62
     * @return int
63
     */
64
    protected function getUpcomingCount()
65
    {
66
        return $this->getDataStore()->fetchSetting('upcomingCount') ?: 3;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    protected function defaultViewParams()
73
    {
74
        //$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
75
        $protocol = 'http'; // $_SERVER['HTTPS'] ? 'https' : 'http';
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
76
        /**
77
         * @noinspection RealpathInSteamContextInspection
78
         */
79
        $allPlatforms = $this->dataSource->fetchAllPlatforms();
80
        $platformNames = array_map(function (Platform $platform) {
81
            return $platform->getName();
82
        }, $allPlatforms);
83
84
        /** @noinspection RealpathInSteamContextInspection */
85
        $viewParams = [
86
            //'serverInfo' => $protocol . '://' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '/',
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% 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...
87
            'serverInfo' => $protocol . '://127.0.0.1:8000/', //FIXME get server name (from config if not in request?)
88
            'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..'),
89
            'allPlatforms' => $platformNames,
90
        ];
91
        $viewParams['displayOptions'] = $this->getDisplayOptions();
92
93
        return $viewParams;
94
    }
95
}
96