Completed
Push — master ( b23d1e...03b6f4 )
by Jean-Christophe
04:33
created

SemanticComponentsTrait   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 11

Importance

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

12 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
A progress() 0 3 1
A search() 0 3 1
A dimmer() 0 3 1
A modal() 0 5 1
1
<?php
2
3
namespace Ajax\semantic\traits;
4
5
use Ajax\common\components\GenericComponent;
6
use Ajax\semantic\components\Popup;
7
use Ajax\semantic\components\Dropdown;
8
use Ajax\semantic\components\Accordion;
9
use Ajax\common\components\SimpleComponent;
10
use Ajax\semantic\components\Sticky;
11
use Ajax\semantic\components\Checkbox;
12
use Ajax\semantic\components\Rating;
13
use Ajax\semantic\components\Progress;
14
use Ajax\semantic\components\Search;
15
use Ajax\semantic\components\Dimmer;
16
use Ajax\semantic\components\Modal;
17
18
trait SemanticComponentsTrait {
19
20
	public abstract function addComponent(SimpleComponent $component, $attachTo, $params);
21
22
	/**
23
	 *
24
	 * @param string $attachTo
25
	 * @param string|array $params
26
	 * @return GenericComponent
27
	 */
28
	public function generic($attachTo=NULL, $params=NULL) {
29
		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...
30
	}
31
32
	/**
33
	 *
34
	 * @param string $attachTo
35
	 * @param string|array $params
36
	 * @return Popup
37
	 */
38
	public function popup($attachTo=NULL, $params=NULL) {
39
		return $this->addComponent(new Popup($this->js), $attachTo, $params);
40
	}
41
42
	/**
43
	 *
44
	 * @param string $attachTo
45
	 * @param string|array $params
46
	 * @return Dropdown
47
	 */
48
	public function dropdown($attachTo=NULL, $params=NULL) {
49
		return $this->addComponent(new Dropdown($this->js), $attachTo, $params);
50
	}
51
52
	/**
53
	 *
54
	 * @param string $attachTo
55
	 * @param string|array $params
56
	 * @return Accordion
57
	 */
58
	public function accordion($attachTo=NULL, $params=NULL) {
59
		return $this->addComponent(new Accordion($this->js), $attachTo, $params);
60
	}
61
62
	public function sticky($attachTo=NULL, $params=NULL) {
63
		return $this->addComponent(new Sticky($this->js), $attachTo, $params);
64
	}
65
66
	public function checkbox($attachTo=NULL, $params=NULL) {
67
		return $this->addComponent(new Checkbox($this->js), $attachTo, $params);
68
	}
69
70
	public function rating($attachTo=NULL, $params=NULL) {
71
		return $this->addComponent(new Rating($this->js), $attachTo, $params);
72
	}
73
74
	public function progress($attachTo=NULL, $params=NULL) {
75
		return $this->addComponent(new Progress($this->js), $attachTo, $params);
76
	}
77
78
	public function search($attachTo=NULL, $params=NULL) {
79
		return $this->addComponent(new Search($this->js), $attachTo, $params);
80
	}
81
82
	public function dimmer($attachTo=NULL, $params=NULL) {
83
		return $this->addComponent(new Dimmer($this->js), $attachTo, $params);
84
	}
85
86
	public function modal($attachTo=NULL, $params=NULL,$paramsParts=NULL) {
87
		$result= $this->addComponent(new Modal($this->js), $attachTo, $params);
88
		$result->setParamParts($paramsParts);
89
		return $result;
90
	}
91
}