Completed
Push — master ( e2570f...5b8799 )
by Mohamed
01:18
created

WorkingWithWidgets::getWidgetsFor()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 1
dl 0
loc 17
rs 9.3888
c 0
b 0
f 0
1
<?php
2
3
namespace Microboard\Foundations\Traits;
4
5
trait WorkingWithWidgets
6
{
7
    /**
8
     * Get widgets for the specific view.
9
     *
10
     * @param $view
11
     * @return string
12
     */
13
    protected function getWidgetsFor($view)
14
    {
15
        $name = $view . "Widgets";
16
17
        if (
18
            in_array($view, ['create', 'update']) &&
19
            (empty($this->updateWidgets) && empty($this->createWidgets))
0 ignored issues
show
Bug introduced by
The property updateWidgets does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property createWidgets does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
        ) {
21
            $name = 'formsWidgets';
22
        }
23
24
        if (property_exists($this, $name)) {
25
            return $this->$name;
26
        }
27
28
        return null;
29
    }
30
}
31