Passed
Pull Request — master (#83)
by Romain
03:05
created

AccountLink   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 8 1
A __construct() 0 7 1
A create() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Common\Button;
6
7
class AccountLink extends AbstractButton
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $url;
13
14
    /**
15
     * AccountLink constructor.
16
     *
17 1
     * @param string $url
18
     *
19 1
     * @throws \InvalidArgumentException
20
     */
21 1
    public function __construct(string $url)
22
    {
23 1
        parent::__construct(self::TYPE_ACCOUNT_LINK);
24 1
25
        $this->isValidUrl($url);
26
27
        $this->url = $url;
28
    }
29 1
30
    /**
31 1
     * @param string $url
32
     *
33 1
     * @throws \InvalidArgumentException
34
     *
35
     * @return \Kerox\Messenger\Model\Common\Button\AccountLink
36 1
     */
37
    public static function create(string $url): self
38
    {
39
        return new self($url);
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function toArray(): array
46
    {
47
        $array = parent::toArray();
48
        $array += [
49
            'url' => $this->url,
50
        ];
51
52
        return $array;
53
    }
54
}
55