Passed
Push — master ( 13ebde...538c8c )
by Stephen
05:08
created

ImgShieldsUrl::withGlobalParams()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Sfneal\Dependencies\Utils;
4
5
class ImgShieldsUrl extends Url
6
{
7
    /**
8
     * Static URL constructor.
9
     *
10
     * @param  string  $uri
11
     * @return self
12
     */
13
    public static function from(string $uri): self
14
    {
15
        return new self($uri);
16
    }
17
18
    /**
19
     * Url constructor.
20
     *
21
     * @param  string  $uri
22
     * @param  array|null  $params
23
     */
24
    public function __construct(string $uri, array $params = null)
25
    {
26
        parent::__construct('img.shields.io/'.$uri, $params);
27
    }
28
29
    /**
30
     * Merge global Img Shields params with the original params.
31
     *
32
     * @param  array|null  $globalParams
33
     * @return $this
34
     */
35
    public function withGlobalParams(array $globalParams = null): self
36
    {
37
        if (! is_null($globalParams)) {
38
            $this->params = array_merge($this->params ?? [], $globalParams);
39
        }
40
41
        return $this;
42
    }
43
}
44