Test Failed
Push — php7 ( 4ef047 )
by Pascal
03:45
created

UrlFixer::fixPackage()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 16
ccs 0
cts 10
cp 0
crap 12
rs 9.9666
1
<?php
2
3
namespace SSpkS\Output;
4
5
class UrlFixer
6
{
7
    private $urlPrefix;
8
9
    /**
10
     * Prepends given $urlPrefix to all URLs in Package objects.
11
     *
12
     * @param string $urlPrefix Prefix to put before all URLs to make them absolute.
13
     */
14
    public function __construct($urlPrefix)
15
    {
16
        $this->urlPrefix = $urlPrefix;
17
    }
18
19
    /**
20
     * Prepends given prefix to Package $pkg.
21
     *
22
     * @param \SSpkS\Package\Package $pkg Package to work on.
23
     */
24
    public function fixPackage($pkg)
25
    {
26
        $pkg->spk_url = $this->urlPrefix . $pkg->spk;
27
28
        // Make absolute URLs from relative ones
29
        $thumbnail_url = array();
30
        foreach ($pkg->thumbnail as $i => $t) {
31
            $thumbnail_url[$i] = $this->urlPrefix . $t;
32
        }
33
        $pkg->thumbnail_url = $thumbnail_url;
34
35
        $snapshot_url = array();
36
        foreach ($pkg->snapshot as $i => $s) {
37
            $snapshot_url[$i] = $this->urlPrefix . $s;
38
        }
39
        $pkg->snapshot_url = $snapshot_url;
40
    }
41
42
    /**
43
     * Prepends given prefix to all Packages in array $pkgList.
44
     *
45
     * @param \SSpkS\Package\Package[] List of Packages.
0 ignored issues
show
Bug introduced by
The type SSpkS\Output\List was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
     */
47
    public function fixPackageList($pkgList)
48
    {
49
        foreach ($pkgList as $pkg) {
50
            $this->fixPackage($pkg);
51
        }
52
    }
53
}
54