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

Apps/Model/Admin/Main/FormYandexCounter.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Apps\Model\Admin\Main;
4
5
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\Model;
8
9
/**
10
 * Class FormYandexCounter
11
 * @package Apps\Model\Admin\Main
12
 */
13
class FormYandexCounter extends Model
14
{
15
    public $counter;
16
17
    private $_counters;
18
19
    /**
20
     * FormYandexCounter constructor.
21
     * @param array $counters
22
     */
23
    public function __construct(array $counters)
24
    {
25
        $this->_counters = $counters;
26
        parent::__construct(false);
27
    }
28
29
    /**
30
     * Validation rules
31
     * @return array
32
     */
33
    public function rules(): array
34
    {
35
        return [
36
            ['counter', 'required'],
37
            ['counter', 'int']
38
        ];
39
    }
40
41
    /**
42
     * Save counter id to configuration file
43
     */
44
    public function make()
45
    {
46
        $cfg = App::$Properties->getAll('Yandex');
47
        $cfg['metrika']['id'] = (int)$this->counter;
48
49
        App::$Properties->writeConfig('Yandex', $cfg);
0 ignored issues
show
It seems like $cfg can also be of type null; however, parameter $data of Ffcms\Core\Properties::writeConfig() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
        App::$Properties->writeConfig('Yandex', /** @scrutinizer ignore-type */ $cfg);
Loading history...
50
    }
51
52
    /**
53
     * Get counter id->name
54
     * @return array
55
     */
56
    public function getCounters(): array
57
    {
58
        return $this->_counters;
59
    }
60
}