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 ( dd13da...b61209 )
by Richard
04:01 queued 54s
created

CssController::customCssAction()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 8.7972
c 0
b 0
f 0
cc 4
eloc 13
nc 4
nop 0
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
        }
33
34
        $data .= $customCss;
35
36
        return new Response($data, 200, $headers);
37
    }
38
}
39