Code Duplication    Length = 8-9 lines in 2 locations

Ajax/common/components/BaseComponent.php 1 location

@@ 59-66 (lines=8) @@
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

Ajax/common/html/BaseHtml.php 1 location

@@ 60-68 (lines=9) @@
57
	}
58
59
	protected function ctrl($name, $value, $typeCtrl) {
60
		if (\is_array($typeCtrl)) {
61
			if (array_search($value, $typeCtrl) === false) {
62
				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
63
			}
64
		} else {
65
			if (!$typeCtrl($value)) {
66
				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
67
			}
68
		}
69
		return true;
70
	}
71