Passed
Push — master ( 6221c1...b56763 )
by Mihail
05:30
created

FormSettings::labels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 7
rs 9.4285
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
class FormSettings extends Model
12
{
13
    public $itemPerApp;
14
    public $minLength;
15
16
    /**
17
     * Construct model with default values
18
     * @param array $configs
19
     */
20 View Code Duplication
    public function __construct(array $configs)
0 ignored issues
show
Duplication introduced by
This method 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...
21
    {
22
        foreach ($configs as $property => $value) {
23
            if (property_exists($this, $property)) {
24
                $this->$property = $value;
25
            }
26
        }
27
28
        parent::__construct();
29
    }
30
31
    /**
32
    * Labels for admin settings form
33
    */
34
    public function labels()
35
    {
36
        return [
37
            'itemPerApp' => __('Search count'),
38
            'minLength' => __('Min length')
39
        ];
40
    }
41
42
    /**
43
    * Validation rules
44
    */
45
    public function rules()
46
    {
47
        return [
48
            [['itemPerApp', 'minLength'], 'required'],
49
            [['itemPerApp', 'minLength'], 'int']
50
        ];
51
    }
52
}