Completed
Push — master ( e6adfa...acb755 )
by Nekrasov
02:15
created

WidgetGroupCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Arrilot\Widgets;
4
5
use Arrilot\Widgets\Contracts\ApplicationWrapperContract;
6
7
class WidgetGroupCollection
8
{
9
    
10
    /**
11
     * The array of widget groups.
12
     *
13
     * @var array
14
     */
15
    protected $groups;
16
17
    /**
18
     * Constructor.
19
     *
20
     * @param ApplicationWrapperContract $app
21
     */
22
    public function __construct(ApplicationWrapperContract $app)
23
    {
24
        $this->app = $app;
0 ignored issues
show
Bug introduced by
The property app 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...
25
    }
26
27
    /**
28
     * Get the widget group object.
29
     *
30
     * @param $name
31
     *
32
     * @return WidgetGroup
33
     */
34
    public function group($name)
35
    {
36
        if (isset($this->groups[$name])) {
37
            return $this->groups[$name];
38
        }
39
40
        $this->groups[$name] = new WidgetGroup($name, $this->app);
41
42
        return $this->groups[$name];
43
    }
44
}
45