AccountLink::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
     * @throws \Kerox\Messenger\Exception\MessengerException
18
     */
19 1
    public function __construct(string $url)
20
    {
21 1
        parent::__construct(self::TYPE_ACCOUNT_LINK);
22
23 1
        $this->isValidUrl($url);
24
25 1
        $this->url = $url;
26 1
    }
27
28
    /**
29
     * @throws \Kerox\Messenger\Exception\MessengerException
30
     *
31
     * @return \Kerox\Messenger\Model\Common\Button\AccountLink
32
     */
33 1
    public static function create(string $url): self
34
    {
35 1
        return new self($url);
36
    }
37
38 1
    public function toArray(): array
39
    {
40 1
        $array = parent::toArray();
41
        $array += [
42 1
            'url' => $this->url,
43
        ];
44
45 1
        return $array;
46
    }
47
}
48