Completed
Push — master ( c4e7d6...313b43 )
by wen
12:00
created

Markdown::isAutoInit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
class Markdown extends NamedElement
6
{
7
    protected $type = 'markdown';
8
9
    protected $configs;
10
11
    protected $highlight = true;
12
13
    protected $autoInit = true;
14
15
    /**
16
     * @return array
17
     */
18
    public function getConfigs(): array
19
    {
20
        if ($this->configs) {
21
            return $this->configs;
22
        }
23
24
        return $this->getDefaultConfigs();
25
    }
26
27
    protected function getDefaultConfigs()
28
    {
29
        return [
30
            'autoDownloadFontAwesome' => false,
31
        ];
32
    }
33
34
    /**
35
     * @param array $configs
36
     *
37
     * @return Markdown
38
     */
39
    public function setConfigs(array $configs): Markdown
40
    {
41
        $this->configs = $configs;
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return bool
48
     */
49
    public function isHighlight(): bool
50
    {
51
        return $this->highlight ? true : false;
52
    }
53
54
    /**
55
     *
56
     * @return Markdown
57
     */
58
    public function disableHighlight(): Markdown
59
    {
60
        $this->highlight = false;
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68
    public function isAutoInit(): bool
69
    {
70
        return $this->autoInit ? true : false;
71
    }
72
73
    /**
74
     *
75
     * @return Markdown
76
     */
77
    public function disableAutoInit(): Markdown
78
    {
79
        $this->autoInit = false;
80
81
        return $this;
82
    }
83
84
    public function toArray()
85
    {
86
        return parent::toArray() + [
87
                'configs'   => $this->getConfigs(),
88
                'highlight' => $this->isHighlight(),
89
                'autoInit'  => $this->isAutoInit(),
90
            ];
91
    }
92
}
93