Passed
Push — master ( cc7747...d2190f )
by Mihail
10:36
created

FormSettings::before()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 4
nop 0
dl 11
loc 11
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Model\Admin\Search;
4
5
use Ffcms\Core\Arch\Model;
6
7
/**
8
 * Class FormSettings. Model to transfer and validate input data & attributes for search admin configs.
9
 * @package Apps\Model\Admin\Search
10
 */
11 View Code Duplication
class FormSettings extends Model
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    public $itemPerApp;
14
    public $minLength;
15
16
    private $_configs;
17
18
    /**
19
     * ForumSettings constructor. Construct model with default values
20
     * @param array|null $configs
21
     */
22
    public function __construct(array $configs = null)
23
    {
24
        $this->_configs = $configs;
25
        parent::__construct();
26
    }
27
28
    public function before()
29
    {
30
        if ($this->_configs === null) {
31
            return;
32
        }
33
        foreach ($this->_configs as $property => $value) {
34
            if (property_exists($this, $property)) {
35
                $this->$property = $value;
36
            }
37
        }
38
    }
39
40
    /**
41
     * Labels for admin settings form
42
     * @return array
43
     */
44
    public function labels()
45
    {
46
        return [
47
            'itemPerApp' => __('Search count'),
48
            'minLength' => __('Min length')
49
        ];
50
    }
51
52
    /**
53
     * Validation rules
54
     * @return @array
0 ignored issues
show
Documentation introduced by
The doc-type @array could not be parsed: Unknown type name "@array" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
55
     */
56
    public function rules()
57
    {
58
        return [
59
            [['itemPerApp', 'minLength'], 'required'],
60
            [['itemPerApp', 'minLength'], 'int']
61
        ];
62
    }
63
}