Completed
Pull Request — master (#44)
by yuuki
01:19
created

AbstractDocument   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
document() 0 1 ?
A __toString() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ytake\LaravelCouchbase\Design;
5
6
/**
7
 * Class AbstractDocument
8
 */
9
abstract class AbstractDocument
10
{
11
    /** @var string */
12
    private $name;
13
14
    /**
15
     * AbstractDocument constructor.
16
     *
17
     * @param string $name
18
     */
19
    public function __construct(string $name)
20
    {
21
        $this->name = $name;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    abstract protected function document(): string;
28
29
    /**
30
     * @return string
31
     */
32
    public function __toString(): string
33
    {
34
        return json_encode([
35
            $this->name => [
36
                'map' => $this->document(),
37
            ],
38
        ]);
39
    }
40
}
41