Completed
Push — master ( 633f87...d85777 )
by Cheren
03:16
created

TextareaWidget   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 9 1
1
<?php
2
/**
3
 * CakeCMS Core
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package     Core
10
 * @license     MIT
11
 * @copyright   MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link        https://github.com/CakeCMS/Core".
13
 * @author      Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Core\View\Widget\MaterializeCss;
17
18
use JBZoo\Utils\Str;
19
use Cake\View\Form\ContextInterface;
20
use Cake\View\Widget\TextareaWidget as CakeTextareaWidget;
21
22
/**
23
 * Class TextareaWidget
24
 *
25
 * @package Core\View\Widget\MaterializeCss
26
 */
27
class TextareaWidget extends CakeTextareaWidget
28
{
29
30
    /**
31
     * Render a text area form widget.
32
     *
33
     * Data supports the following keys:
34
     *
35
     * - `name` - Set the input name.
36
     * - `val` - A string of the option to mark as selected.
37
     * - `escape` - Set to false to disable HTML escaping.
38
     *
39
     * All other keys will be converted into HTML attributes.
40
     *
41
     * @param   array $data The data to build a textarea with.
42
     * @param   \Cake\View\Form\ContextInterface $context The current form context.
43
     * @return  string HTML elements.
44
     */
45
    public function render(array $data, ContextInterface $context)
46
    {
47
        $data = array_merge(['class' => null], $data);
48
49
        $data['class'] .= ' materialize-textarea';
50
        $data['class'] = Str::trim($data['class']);
51
52
        return parent::render($data, $context);
53
    }
54
}
55