Document::getMetadata()   A
last analyzed

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
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Kurenai;
4
5
use Illuminate\Support\Arr;
6
7
/**
8
 * Class Document
9
 *
10
 * @package \Kurenai
11
 */
12
class Document
13
{
14
    /**
15
     * Raw document content.
16
     *
17
     * @var string
18
     */
19
    protected $raw;
20
21
    /**
22
     * Document metadata.
23
     *
24
     * @var mixed
25
     */
26
    protected $metadata;
27
28
    /**
29
     * Document content.
30
     *
31
     * @var string
32
     */
33
    protected $content;
34
35
    /**
36
     * Document constructor.
37
     *
38
     * @param string $raw
39
     * @param mixed  $metdata
40
     * @param string $content
41
     */
42 8
    public function __construct($raw, $metdata, $content)
43
    {
44 8
        $this->raw      = $raw;
45 8
        $this->metadata = $metdata;
46 8
        $this->content  = $content;
47 8
    }
48
49
    /**
50
     * Get the raw document.
51
     *
52
     * @return string
53
     */
54 2
    public function getRaw()
55
    {
56 2
        return $this->raw;
57
    }
58
59
    /**
60
     * Get the document metadata.
61
     *
62
     * @return mixed
63
     */
64 2
    public function getMetadata()
65
    {
66 2
        return $this->metadata;
67
    }
68
69
    /**
70
     * Get the document content.
71
     *
72
     * @return string
73
     */
74 2
    public function getContent()
75
    {
76 2
        return $this->content;
77
    }
78
79
    /**
80
     * Get a metadata value using dot notation.
81
     *
82
     * @param string $key
83
     * @param mixed  $default
84
     *
85
     * @return mixed
86
     */
87 2
    public function get($key, $default = null)
88
    {
89 2
        return Arr::get($this->metadata, $key, $default);
90
    }
91
}
92