Passed
Push — develop ( 616438...84d7aa )
by Nikolay
06:16 queued 11s
created

AssetManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A outputCss() 0 7 2
A outputJs() 0 7 2
A setVersion() 0 3 1
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright (C) 2017-2021 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
namespace MikoPBX\AdminCabinet\Plugins;
21
22
23
use Phalcon\Assets\Manager;
24
25
class AssetManager extends Manager
26
{
27
    private string $version;
28
29
    /**
30
     * Sets asset versions
31
     *
32
     * @param string $version
33
     */
34
    public function setVersion(string $version)
35
    {
36
        $this->version = $version;
37
    }
38
39
    /**
40
     * Prints the HTML for CSS assets
41
     *
42
     * @param string $collectionName
43
     *
44
     * @return string
45
     */
46
    public function outputCss(string $collectionName = null): string
47
    {
48
        foreach ($this->collection($collectionName) as $resource) {
0 ignored issues
show
Bug introduced by
It seems like $collectionName can also be of type null; however, parameter $name of Phalcon\Assets\Manager::collection() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
        foreach ($this->collection(/** @scrutinizer ignore-type */ $collectionName) as $resource) {
Loading history...
49
            $resource->setVersion($this->version);
50
        }
51
52
        return parent::outputCss($collectionName);
53
    }
54
55
    /**
56
     * Prints the HTML for JS assets
57
     *
58
     * @param string $collectionName
59
     *
60
     * @return string
61
     */
62
    public function outputJs(string $collectionName = null): string
63
    {
64
        foreach ($this->collection($collectionName) as $resource) {
0 ignored issues
show
Bug introduced by
It seems like $collectionName can also be of type null; however, parameter $name of Phalcon\Assets\Manager::collection() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
        foreach ($this->collection(/** @scrutinizer ignore-type */ $collectionName) as $resource) {
Loading history...
65
            $resource->setVersion($this->version);
66
        }
67
68
        return parent::outputJs($collectionName);
69
    }
70
71
}