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

Destination   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 32
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
jsonRepresentation() 0 1 ?
A type() 0 4 1
A typedJsonRepresentation() 0 7 1
fromJsonRepresentation() 0 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
}