Completed
Push — master ( 062b68...81f5ad )
by Terzi
08:48
created

Textarea   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 73
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A markdown() 0 5 1
A editorEnabled() 0 3 1
A tinymce() 0 5 1
A medium() 0 5 1
A ckeditor() 0 5 1
A onEdit() 0 5 2
1
<?php
2
3
namespace Terranet\Administrator\Field;
4
5
use Terranet\Administrator\Scaffolding;
6
7
class Textarea extends Generic
8
{
9
    const EDITOR_TINYMCE = 'tinymce';
10
    const EDITOR_CKEDITOR = 'ckeditor';
11
    const EDITOR_MEDIUM = 'medium';
12
    const EDITOR_MARKDOWN = 'markdown';
13
14
    /** @var array */
15
    protected $visibility = [
16
        Scaffolding::PAGE_INDEX => false,
17
        Scaffolding::PAGE_EDIT => true,
18
        Scaffolding::PAGE_VIEW => true,
19
    ];
20
21
    protected $editor = false;
22
23
    /**
24
     * @param $editor
25
     * @return bool
26
     */
27
    public function editorEnabled($editor)
28
    {
29
        return $editor === $this->editor;
30
    }
31
32
    /**
33
     * @return $this
34
     */
35
    public function tinymce()
36
    {
37
        $this->editor = static::EDITOR_TINYMCE;
38
39
        return $this;
40
    }
41
42
    /**
43
     * @return $this
44
     */
45
    public function ckeditor()
46
    {
47
        $this->editor = static::EDITOR_CKEDITOR;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @return $this
54
     */
55
    public function medium()
56
    {
57
        $this->editor = static::EDITOR_MEDIUM;
58
59
        return $this;
60
    }
61
62
    /**
63
     * @return $this
64
     */
65
    public function markdown()
66
    {
67
        $this->editor = static::EDITOR_MARKDOWN;
68
69
        return $this;
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function onEdit()
76
    {
77
        return $this->editor ? [
78
            'dataEditor' => $this->editor,
79
        ] : [];
80
    }
81
}
82