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

AccountLink::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
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