Passed
Push — master ( 66351d...335aef )
by Hirofumi
20:01
created

SlackChannelDestination   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A channel() 0 4 1
A jsonRepresentation() 0 4 1
A fromJsonRepresentation() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shippinno\Notification\Domain\Model;
5
6
class SlackChannelDestination extends Destination
7
{
8
    /**
9
     * @var string
10
     */
11
    private $channel;
12
13
    /**
14
     * @param string $channel
15
     */
16 3
    public function __construct(string $channel)
17
    {
18 3
        $this->channel = $channel;
19 3
    }
20
21
    /**
22
     * @return string
23
     */
24 2
    public function channel(): string
25
    {
26 2
        return $this->channel;
27
    }
28
29
    /**
30
     * @return string
31
     */
32 1
    public function jsonRepresentation(): string
33
    {
34 1
        return json_encode(['channel' => $this->channel()]);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public static function fromJsonRepresentation(string $jsonRepresentation): Destination
41
    {
42 1
        $decoded = json_decode($jsonRepresentation, true);
43
44 1
        return new SlackChannelDestination($decoded['channel']);
45
    }
46
}
47