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

State::add()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 8.8571
cc 5
eloc 7
nc 8
nop 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
}