Completed
Push — master ( 8b7375...189ad5 )
by Jean-Christophe
03:49
created

State   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B add() 0 12 5
A _add() 0 5 2
1
<?php
2
3
namespace Ajax\semantic\html\base\constants;
4
5
use Ajax\common\BaseEnum;
6
use Ajax\common\html\BaseHtml;
7
8
abstract class State extends BaseEnum {
9
	const ACTIVE="active", DISABLED="disabled", ERROR="error", FOCUS="focus", LOADING="loading", NEGATIVE="negative", POSITIVE="positive", SUCCESS="success", WARNING="warning";
10
11
	public static function add($state, $elements) {
12
		if (\is_array($state) === false) {
13
			$state=\explode(" ", $state);
14
		}
15
		if (\is_array($elements)) {
16
			foreach ( $elements as $element ) {
17
				if ($element instanceof BaseHtml) {
18
					self::_add($state, $element);
19
				}
20
			}
21
		}
22
	}
23
24
	private static function _add($states, $element) {
25
		foreach ( $states as $state ) {
26
			$element->addToPropertyCtrl("class", $state, array ($state ));
27
		}
28
	}
29
}