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

SlackChannelDestination::destinationType()   A

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 0
crap 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