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.

CssController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B customCssAction() 0 25 4
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: wechsler
5
 * Date: 24/02/2017
6
 * Time: 20:39
7
 */
8
9
namespace Phase\TakeATicketBundle\Controller;
10
11
use Symfony\Component\HttpFoundation\Response;
12
13
class CssController extends BaseController
14
{
15
    public function customCssAction()
16
    {
17
        $backgroundFilename = $this->getDataStore()->fetchSetting('backgroundFilename');
18
        $customCss = $this->getDataStore()->fetchSetting('customCss');
19
        $backgroundFullPath = dirname($this->get('kernel')->getRootDir()) . '/web/uploads/' . $backgroundFilename;
20
21
        $backgroundUrl = null;
22
        if ($backgroundFilename && file_exists($backgroundFullPath)) {
23
            $backgroundUrl = '/uploads/' . $backgroundFilename;
24
        }
25
26
        $headers = ['Content-type' => 'text/css'];
27
28
        $data = '';
29
30
        if ($backgroundUrl) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $backgroundUrl of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
31
            $data .= "body {\n\tbackground-image: url('$backgroundUrl');\n\tbackground-size: cover;\n}\n";
32
            $data .= "@media only screen and (max-device-width: 480px)" .
33
                "\n{\tbody {\n\tbackground-image: none !important;\n\t}\n}";
34
        }
35
36
        $data .= $customCss;
37
38
        return new Response($data, 200, $headers);
39
    }
40
}
41