Passed
Push — master ( 0456bd...25822b )
by Mihail
07:10
created

FormYandexConnect::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Apps\Model\Admin\Main;
4
5
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\Model;
8
use Ffcms\Templex\Url\Url;
9
10
/**
11
 * Class FormYandexConnect
12
 * @package Apps\Model\Admin\Main
13
 */
14
class FormYandexConnect extends Model
15
{
16
    public $callback;
17
    public $appid;
18
19
    private $_configs;
20
21
    /**
22
     * FormYandexConnect constructor.
23
     * @param array $configs
24
     */
25
    public function __construct(array $configs)
26
    {
27
        $this->_configs = $configs;
28
        parent::__construct(false);
29
    }
30
31
    /**
32
     * Process before features
33
     */
34
    public function before()
35
    {
36
        $this->appid = $this->_configs['oauth']['app_id'];
37
        $this->callback = Url::to('main/yandextoken');
38
    }
39
40
    /**
41
     * Display labels
42
     * @return array
43
     */
44
    public function labels(): array
45
    {
46
        return [
47
            'callback' => 'Callback URI',
48
            'appid' => 'ID'
49
        ];
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function rules(): array
56
    {
57
        return [
58
            ['appid', 'required'],
59
            ['appid', 'length_min', 32]
60
        ];
61
    }
62
63
    /**
64
     * Make save configs
65
     */
66
    public function make()
67
    {
68
        $cfg = $this->_configs;
69
        $cfg['oauth']['app_id'] = $this->appid;
70
71
        App::$Properties->writeConfig('Yandex', $cfg);
72
    }
73
}