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

ImgShieldsUrl   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 37
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A withGlobalParams() 0 7 2
A from() 0 3 1
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