function Factory::createInstanceFor
Create a constraint instance for the given constraint name.
Parameters
string $constraintName:
Return value
ConstraintInterface|ObjectConstraint
Throws
InvalidArgumentException if is not possible create the constraint instance
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ Constraints/ Factory.php, line 188
Class
- Factory
- Factory for centralize constraint initialization.
Namespace
JsonSchema\ConstraintsCode
public function createInstanceFor($constraintName) {
if (!isset($this->constraintMap[$constraintName])) {
throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
}
if (!isset($this->instanceCache[$constraintName])) {
$this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
}
return clone $this->instanceCache[$constraintName];
}