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

WorkingWithWidgets   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getWidgetsFor() 0 17 5
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