Passed
Push — master ( 68443e...939347 )
by Mihail
04:31
created

FormSettings   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A before() 0 8 3
A rules() 0 7 1
A labels() 0 7 1
1
<?php
2
3
namespace Apps\Model\Admin\Feedback;
4
5
6
use Ffcms\Core\Arch\Model;
7
8
class FormSettings extends Model
9
{
10
    public $guestAdd;
11
    public $useCaptcha;
12
13
    /** @var array $_configs */
14
    private $_configs;
15
16
    /**
17
     * FormSettings constructor. Pass array of configs inside the model
18
     * @param array $configs
19
     */
20
    public function __construct(array $configs)
21
    {
22
        $this->_configs = $configs;
23
        parent::__construct();
24
    }
25
26
    /**
27
     * Set default model values by passed config array
28
     */
29
    public function before()
30
    {
31
        foreach ($this->_configs as $property => $value) {
32
            if (property_exists($this, $property)) {
33
                $this->$property = $value;
34
            }
35
        }
36
    }
37
38
    /**
39
     * Validation rules
40
     * @return array
41
     */
42
    public function rules()
43
    {
44
        return [
45
            [['guestAdd', 'useCaptcha'], 'required'],
46
            [['guestAdd', 'useCaptcha'], 'int'],
47
        ];
48
    }
49
50
    /**
51
     * Labels to display in form
52
     * @return array
53
     */
54
    public function labels()
55
    {
56
        return [
57
            'guestAdd' => __('Guest add'),
58
            'useCaptcha' => __('Use captcha')
59
        ];
60
    }
61
62
}