SettingsModal   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0
ccs 0
cts 11
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 11 2
1
<?php
2
/**
3
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\widgets;
12
13
use hipanel\base\Model;
14
use hipanel\helpers\FontIcon;
15
use yii\helpers\Html;
16
17
/**
18
 * Class SettingsModal. Render AjaxModal, created specially to render on view page.
19
 */
20
class SettingsModal extends AjaxModal
21
{
22
    /**
23
     * @var Model
24
     */
25
    public $model;
26
27
    /**
28
     * @var string text of toggle link
29
     */
30
    public $title;
31
32
    /**
33
     * @var string template for `label` attribute
34
     */
35
    public $labelTemplate = '{icon} {label}';
36
37
    /**
38
     * @var string icon class for toggle link
39
     * Will be passed through [[FontIcon::i()]] method
40
     */
41
    public $icon;
42
43
    public function init()
44
    {
45
        $this->header = Html::tag('h4', $this->title, ['class' => 'modal-title']);
46
        $this->actionUrl = [$this->scenario, 'id' => $this->model->id];
0 ignored issues
show
Bug introduced by
The property actionUrl does not seem to exist. Did you mean _actionUrl?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Documentation introduced by
The property id does not exist on object<hipanel\base\Model>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
47
        $this->toggleButton = array_merge([
48
            'tag' => 'a',
49
            'label' => strtr($this->labelTemplate, ['{icon}' => FontIcon::i($this->icon), '{label}' => $this->title]),
50
            'class' => 'clickable',
51
        ], is_array($this->toggleButton) ? $this->toggleButton : []);
52
        parent::init();
53
    }
54
}
55