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

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