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

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