FormSettings   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 28
dl 0
loc 62
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A before() 0 9 4
A labels() 0 10 1
A rules() 0 6 1
1
<?php
2
3
namespace Apps\Model\Admin\Profile;
4
5
use Ffcms\Core\Arch\Model;
6
7
/**
8
 * Class FormSettings. Admin profile settings business logic
9
 * @package Apps\Model\Admin\Profile
10
 */
11
class FormSettings extends Model
12
{
13
    public $guestView;
14
    public $wallPostOnPage;
15
    public $wallPostOnFeed;
16
    public $delayBetweenPost;
17
    public $rating;
18
    public $usersOnPage;
19
    public $ratingDelay;
20
21
    private $_configs;
22
23
    /**
24
     * Construct model with default values
25
     * @param array|null $configs
26
     */
27
    public function __construct(array $configs = null)
28
    {
29
        $this->_configs = $configs;
30
        parent::__construct();
31
    }
32
33
    public function before()
34
    {
35
        if ($this->_configs === null) {
36
            return;
37
        }
38
39
        foreach ($this->_configs as $property => $value) {
40
            if (property_exists($this, $property)) {
41
                $this->{$property} = $value;
42
            }
43
        }
44
    }
45
46
    /**
47
     * Form display labels
48
     * @return array
49
     */
50
    public function labels(): array
51
    {
52
        return [
53
            'guestView' => __('Guest view'),
54
            'wallPostOnPage' => __('Posts in profile'),
55
            'wallPostOnFeed' => __('Posts on feed'),
56
            'delayBetweenPost' => __('Post delay'),
57
            'rating' => __('Rating'),
58
            'usersOnPage' => __('User per page'),
59
            'ratingDelay' => __('Rating delay')
60
        ];
61
    }
62
63
    /**
64
     * Validation rules
65
     * @return array
66
     */
67
    public function rules(): array
68
    {
69
        return [
70
            [['guestView', 'wallPostOnPage', 'delayBetweenPost', 'rating', 'usersOnPage', 'ratingDelay', 'wallPostOnFeed'], 'required'],
71
            [['wallPostOnPage', 'delayBetweenPost', 'usersOnPage', 'ratingDelay', 'wallPostOnFeed'], 'int'],
72
            [['guestView', 'rating'], 'boolean']
73
        ];
74
    }
75
}
76