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

AbstractDocument::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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