Document::setContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This is part of the webuni/front-matter package.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 * (c) Webuni s.r.o. <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Webuni\FrontMatter;
14
15
class Document
16
{
17
    /** @var string */
18
    private $content;
19
20
    /** @var array<string, mixed> */
21
    private $data;
22
23
    /**
24
     * @param string $content
25
     * @param array<string, mixed> $data
26
     */
27
    public function __construct(string $content = '', array $data = [])
28
    {
29
        $this->content = $content;
30
        $this->data = $data;
31
    }
32
33
    public function getContent(): string
34
    {
35
        return $this->content;
36
    }
37
38
    /**
39
     * @return array<string, mixed>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
40
     */
41
    public function getData(): array
42
    {
43
        return $this->data;
44
    }
45
46
    public function getDataWithContent(string $key = '__content'): array
47
    {
48
        return array_merge($this->data, [$key => $this->content]);
49
    }
50
51
    public function setContent(string $content): self
52
    {
53
        $this->content = $content;
54
55
        return $this;
56
    }
57
58
    /**
59
     * @param array<string, mixed> $data
60
     * @return $this
61
     */
62
    public function setData(array $data): self
63
    {
64
        $this->data = $data;
65
66
        return $this;
67
    }
68
69
    public function __toString(): string
70
    {
71
        return $this->content;
72
    }
73
}
74