Completed
Push — master ( 66af5c...1d23a1 )
by Jean-Christophe
03:38
created

SemanticComponentsTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 7
c 6
b 0
f 0
lcom 1
cbo 7
dl 0
loc 53
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
addComponent() 0 1 ?
A generic() 0 3 1
A popup() 0 3 1
A dropdown() 0 3 1
A accordion() 0 3 1
A sticky() 0 3 1
A checkbox() 0 3 1
A rating() 0 3 1
1
<?php
2
3
namespace Ajax\semantic\traits;
4
use Ajax\common\components\GenericComponent;
5
use Ajax\semantic\components\Popup;
6
use Ajax\semantic\components\Dropdown;
7
use Ajax\semantic\components\Accordion;
8
use Ajax\common\components\SimpleComponent;
9
use Ajax\semantic\components\Sticky;
10
use Ajax\semantic\components\Checkbox;
11
use Ajax\semantic\components\Rating;
12
trait SemanticComponentsTrait {
13
14
	public abstract function addComponent(SimpleComponent $component, $attachTo, $params);
15
	/**
16
	 *
17
	 * @param string $attachTo
18
	 * @param string|array $params
19
	 * @return GenericComponent
20
	 */
21
	public function generic($attachTo=NULL, $params=NULL) {
22
		return $this->addComponent(new GenericComponent($this->js), $attachTo, $params);
0 ignored issues
show
Bug introduced by
The property js 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...
23
	}
24
	/**
25
	 *
26
	 * @param string $attachTo
27
	 * @param string|array $params
28
	 * @return Popup
29
	 */
30
	public function popup($attachTo=NULL, $params=NULL) {
31
		return $this->addComponent(new Popup($this->js), $attachTo, $params);
32
	}
33
34
	/**
35
	 * @param string $attachTo
36
	 * @param string|array $params
37
	 * @return Dropdown
38
	 */
39
	public function dropdown($attachTo=NULL, $params=NULL) {
40
		return $this->addComponent(new Dropdown($this->js), $attachTo, $params);
41
	}
42
43
	/**
44
	 * @param string $attachTo
45
	 * @param string|array $params
46
	 * @return Accordion
47
	 */
48
	public function accordion($attachTo=NULL, $params=NULL) {
49
		return $this->addComponent(new Accordion($this->js), $attachTo, $params);
50
	}
51
52
	public function sticky($attachTo=NULL, $params=NULL) {
53
		return $this->addComponent(new Sticky($this->js), $attachTo, $params);
54
	}
55
56
	public function checkbox($attachTo=NULL, $params=NULL) {
57
		return $this->addComponent(new Checkbox($this->js), $attachTo, $params);
58
	}
59
60
	public function rating($attachTo=NULL, $params=NULL) {
61
		return $this->addComponent(new Rating($this->js), $attachTo, $params);
62
	}
63
64
}