MarkdownDocument   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 62
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getParams() 0 4 1
A getParam() 0 7 2
A getContent() 0 4 1
1
<?php
2
/**
3
 * Lichtenwallner  (https://lichtenwallner.at)
4
 *
5
 * @see https://github.com/jolicht/markdown-cms for the canonical source repository
6
 * @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
7
 * @copyright Copyright (c) Johannes Lichtenwallner
8
 */
9
declare(strict_types = 1);
10
namespace Jolicht\MarkdownCms\Markdown;
11
12
/**
13
 * Markdown document
14
 *
15
 * providing yaml params and content of markdown document
16
 */
17
class MarkdownDocument
18
{
19
    /**
20
     * Params
21
     *
22
     * @var array
23
     */
24
    private $params;
25
26
    /**
27
     * Content
28
     *
29
     * @var string
30
     */
31
    private $content;
32
33
    /**
34
     * Constructor
35
     *
36
     * @param array $params
37
     * @param string $content
38
     */
39
    public function __construct(array $params, string $content)
40
    {
41
        $this->params = $params;
42
        $this->content = $content;
43
    }
44
45
    /**
46
     * Get params
47
     *
48
     * @return array
49
     */
50
    public function getParams() : array
51
    {
52
        return $this->params;
53
    }
54
55
    /**
56
     * Get param
57
     *
58
     * @param string $key
59
     * @return mixed
60
     */
61
    public function getParam($key, $default = null)
62
    {
63
        if (isset($this->params[$key])) {
64
            return $this->params[$key];
65
        }
66
        return $default;
67
    }
68
69
    /**
70
     * Get content
71
     *
72
     * @return string
73
     */
74
    public function getContent() : string
75
    {
76
        return $this->content;
77
    }
78
}