Subscriber::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
4
namespace SirSova\Webhooks\Subscribers;
5
6
use SirSova\Webhooks\Contracts\Subscriber as SubscriberContract;
7
8
class Subscriber implements SubscriberContract
9
{
10
    /**
11
     * @var string
12
     */
13
    private $event;
14
    /**
15
     * @var string
16
     */
17
    private $url;
18
    /**
19
     * @var bool
20
     */
21
    private $enabled;
22
    
23
    public function __construct(string $event, string $url, bool $enabled = true)
24
    {
25
        $this->event = $event;
26
        $this->url = $url;
27
        $this->enabled = $enabled;
28
    }
29
30
    public function event(): string
31
    {
32
        return $this->event;
33
    }
34
    
35
    public function url(): string
36
    {
37
        return $this->url;
38
    }
39
    
40
    public function isEnabled(): bool
41
    {
42
        return $this->enabled;
43
    }
44
    
45
    public function toArray(): array
46
    {
47
        return [
48
            'event'   => $this->event(),
49
            'url'     => $this->url(),
50
            'enabled' => $this->isEnabled()
51
        ];
52
    }
53
}
54