Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/Model/Admin/Search/FormSettings.php (1 issue)

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
    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(): array
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 Bug introduced by zenn
The doc comment @array at position 0 could not be parsed: Unknown type name '@array' at position 0 in @array.
Loading history...
55
     */
56
    public function rules(): array
57
    {
58
        return [
59
            [['itemPerApp', 'minLength'], 'required'],
60
            [['itemPerApp', 'minLength'], 'int']
61
        ];
62
    }
63
}
64