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

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