Code Duplication    Length = 11-12 lines in 2 locations

Ajax/common/BaseComponent.php 1 location

@@ 58-68 (lines=11) @@
55
		$js->addToCompile($script);
56
	}
57
58
	protected function setParamCtrl($key, $value, $typeCtrl) {
59
		if (is_array($typeCtrl)) {
60
			if (array_search($value, $typeCtrl)===false)
61
				throw new \Exception("La valeur passée a propriété `".$key."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
62
		} else {
63
			if (!$typeCtrl($value)) {
64
				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key);
65
			}
66
		}
67
		$this->setParam($key, $value);
68
	}
69
70
	public function setParams($params) {
71
		foreach ( $params as $k => $v ) {

Ajax/common/html/BaseHtml.php 1 location

@@ 97-108 (lines=12) @@
94
		return $result;
95
	}
96
97
	protected function ctrl($name, $value, $typeCtrl) {
98
		if (is_array($typeCtrl)) {
99
			if (array_search($value, $typeCtrl)===false) {
100
				throw new \Exception("La valeur passée a propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
101
			}
102
		} else {
103
			if (!$typeCtrl($value)) {
104
				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
105
			}
106
		}
107
		return true;
108
	}
109
110
	protected function setPropertyCtrl($name, $value, $typeCtrl) {
111
		if ($this->ctrl($name, $value, $typeCtrl)===true)