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

Destination::typedJsonRepresentation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
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
use Verraes\ClassFunctions\ClassFunctions;
7
8
abstract class Destination
9
{
10
    /**
11
     * @return string
12
     */
13
    abstract public function destinationType(): string;
14
15
    /**
16
     * @return string
17
     */
18
    abstract public function jsonRepresentation(): string;
19
20
    /**
21
     * @return string
22
     */
23
    public function typedJsonRepresentation(): string
24
    {
25
        $decoded = json_decode($this->jsonRepresentation(), true);
26
        $decoded['type'] = ClassFunctions::short($this);
27
28
        return json_encode($decoded);
29
    }
30
31
    /**
32
     * @param string $stringRepresentation
33
     * @return Destination
34
     */
35
    abstract public static function fromJsonRepresentation(string $stringRepresentation): Destination;
36
}