function Factory::setConstraintClass
Parameters
string $name:
string $class:
Return value
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ Factory.php, line 164
Class
- Factory
- Factory for centralize constraint initialization.
Namespace
JsonSchema\ConstraintsCode
public function setConstraintClass($name, $class) {
// Ensure class exists
if (!class_exists($class)) {
throw new InvalidArgumentException('Unknown constraint ' . $name);
}
// Ensure class is appropriate
if (!in_array('JsonSchema\\Constraints\\ConstraintInterface', class_implements($class))) {
throw new InvalidArgumentException('Invalid class ' . $name);
}
$this->constraintMap[$name] = $class;
return $this;
}