Test Failed
Push — master ( 8dd30c...47d367 )
by Hirofumi
49:56
created

SlackChannelDestination::jsonRepresentation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 0
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
    public function __construct(string $channel)
17
    {
18
        $this->channel = $channel;
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function channel(): string
25
    {
26
        return $this->channel;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function destinationType(): string
33
    {
34
        return get_class($this);
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function jsonRepresentation(): string
41
    {
42
        return json_encode(['channel' => $this->channel()]);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public static function fromJsonRepresentation(string $jsonRepresentation): Destination
49
    {
50
        $decoded = json_decode($jsonRepresentation, true);
51
52
        return new SlackChannelDestination($decoded['channel']);
53
    }
54
}
55