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.
Test Setup Failed
Push — master ( c5ade0...e039e4 )
by Gabriel
05:51
created

StyleSheets::pack()   C

Complexity

Conditions 7
Paths 10

Size

Total Lines 44
Code Lines 25

Duplication

Lines 6
Ratio 13.64 %

Importance

Changes 0
Metric Value
cc 7
eloc 25
nc 10
nop 1
dl 6
loc 44
rs 6.7272
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A StyleSheets::buildURL() 0 8 2
1
<?php
2
3
namespace Nip\Helpers\View;
4
5
use Nip\Utility\Str;
6
7
/**
8
 * Nip Framework
9
 *
10
 * @category   Nip
11
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
12
 */
13
class StyleSheets extends AbstractHelper
14
{
15
    /**
16
     * @var array
17
     */
18
    protected $files = [];
19
20
    /**
21
     * @param $file
22
     * @param bool $condition
23
     * @return $this
24
     */
25
    public function add($file, $condition = false)
26
    {
27
        $this->files[$condition][$file] = $file;
28
        return $this;
29
    }
30
31
    /**
32
     * @param $file
33
     * @param bool $condition
34
     * @return $this
35
     */
36
    public function prepend($file, $condition = false)
37
    {
38 View Code Duplication
        if (!isset($this->files[$condition]) || !is_array($this->files[$condition])) {
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...
39
            $this->files[$condition] = [];
40
        }
41
        array_unshift($this->files[$condition], $file);
42
        return $this;
43
    }
44
45
    /**
46
     * @param $file
47
     * @param bool $condition
48
     * @return $this
49
     */
50
    public function remove($file, $condition = false)
51
    {
52
        unset($this->files[$condition][$file]);
53
        return $this;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function __toString()
60
    {
61
        $return = '';
62
63
        if (count($this->files)) {
64
            foreach ($this->files as $condition => $files) {
65
                foreach ($files as $file) {
66
                    $return .= $this->buildTag($file, $condition);
67
                }
68
            }
69
        }
70
71
        return $return;
72
    }
73
74
    /**
75
     * @param $path
76
     * @param $condition
77
     * @return string
78
     */
79
    public function buildTag($path, $condition = null)
80
    {
81
        $return = '<link rel="stylesheet" type="text/css" media="screen" href="' . $this->buildURL($path) . '" />';
82
        if ($condition != null && !empty($condition)) {
83
            $return = '<!--[if ' . $condition . ']>' . $return . '<![endif]-->';
84
        }
85
        $return .= "\r\n";
86
87
        return $return;
88
    }
89
90
    /**
91
     * @param $source
92
     * @return string
93
     */
94
    public function buildURL($source)
95
    {
96
        if (Str::startsWith($source, ['http', 'https'])) {
97
            return $source;
98
        } else {
99
            return asset('/stylesheets/' . $source . '.css');
100
        }
101
    }
102
}
103