FormSettings::labels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Apps\Model\Admin\Newcomment;
4
5
use Ffcms\Core\Arch\Model;
6
7
/**
8
 * Class FormSettings. New content widget settings business logic
9
 * @package Apps\Model\Admin\Newcomment
10
 */
11
class FormSettings extends Model
12
{
13
    public $count;
14
    public $snippet;
15
    public $cache;
16
17
    private $_configs;
18
19
    /**
20
     * FormSettings constructor. Pass configs inside from controller
21
     * @param array|null $configs
22
     */
23
    public function __construct(array $configs = null)
24
    {
25
        $this->_configs = $configs;
26
        parent::__construct();
27
    }
28
29
    /**
30
     * Set default values from configs
31
     */
32
    public function before()
33
    {
34
        $this->snippet = (int)$this->_configs['snippet'];
35
        $this->count = (int)$this->_configs['count'];
36
        $this->cache = (int)$this->_configs['cache'];
37
    }
38
39
    /**
40
     * Labels for form display
41
     * @return array
42
     */
43
    public function labels(): array
44
    {
45
        return [
46
            'snippet' => __('Max length'),
47
            'count' => __('Comments count'),
48
            'cache' => __('Cache')
49
        ];
50
    }
51
52
    /**
53
     * Settings validation rules
54
     * @return array
55
     */
56
    public function rules(): array
57
    {
58
        return [
59
            [['snippet', 'count', 'cache'], 'required'],
60
            [['snippet', 'count', 'cache'], 'int']
61
        ];
62
    }
63
}
64