Completed
Push — master ( a51be7...c74983 )
by Antony
02:19
created

CommonComposite   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setObservables() 0 7 2
A getObservables() 0 4 1
1
<?php
2
namespace Knockout;
3
4
trait CommonComposite
5
{
6
    /**
7
     * setObservables
8
     *
9
     * @param array $names The names of the knockout observables.
10
     * @return $this
11
     */
12
    public function setObservables($names)
13
    {
14
        foreach ($this->children as $key => $field) {
0 ignored issues
show
Bug introduced by
The property children 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...
15
            $field->setObservable($names[$key]);
16
        }
17
        return $this;
18
    }
19
20
    /**
21
     * getObservables
22
     *
23
     * @return array The observables used by the children
24
     */
25
    public function getObservables()
26
    {
27
        return $this->children->column('observable');
28
    }
29
}
30
31