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

ImgShieldsUrl::from()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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