Factory
in package
Factory for centralize constraint initialization.
Table of Contents
Properties
- $constraintMap : array<string|int, mixed>
- $errorContext : int
- $schemaStorage : SchemaStorage
- $uriRetriever : UriRetriever
- $checkMode : int
- $instanceCache : array<string|int, ConstraintInterface>
- $typeCheck : array<string|int, TypeCheckInterface>
Methods
- __construct() : mixed
- addConfig() : mixed
- Enable checkMode flags
- createInstanceFor() : ConstraintInterface|ObjectConstraint
- Create a constraint instance for the given constraint name.
- getConfig() : int
- Get checkMode option
- getErrorContext() : string
- Get the error context
- getSchemaStorage() : mixed
- getTypeCheck() : mixed
- getUriRetriever() : UriRetrieverInterface
- removeConfig() : mixed
- Disable checkMode flags
- setConfig() : mixed
- Set config values
- setConstraintClass() : Factory
- setErrorContext() : mixed
- Set the error context
Properties
$constraintMap
protected
array<string|int, mixed>
$constraintMap
= array('array' => 'JsonSchema\Constraints\CollectionConstraint', 'collection' => 'JsonSchema\Constraints\CollectionConstraint', 'object' => 'JsonSchema\Constraints\ObjectConstraint', 'type' => 'JsonSchema\Constraints\TypeConstraint', 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint', 'string' => 'JsonSchema\Constraints\StringConstraint', 'number' => 'JsonSchema\Constraints\NumberConstraint', 'enum' => 'JsonSchema\Constraints\EnumConstraint', 'format' => 'JsonSchema\Constraints\FormatConstraint', 'schema' => 'JsonSchema\Constraints\SchemaConstraint', 'validator' => 'JsonSchema\Validator')
$errorContext
protected
int
$errorContext
= \JsonSchema\Validator::ERROR_DOCUMENT_VALIDATION
Validation context
$schemaStorage
protected
SchemaStorage
$schemaStorage
$uriRetriever
protected
UriRetriever
$uriRetriever
$checkMode
private
int
$checkMode
= \JsonSchema\Constraints\Constraint::CHECK_MODE_NORMAL
$instanceCache
private
array<string|int, ConstraintInterface>
$instanceCache
= array()
$typeCheck
private
array<string|int, TypeCheckInterface>
$typeCheck
= array()
Methods
__construct()
public
__construct([SchemaStorage $schemaStorage = null ][, UriRetrieverInterface $uriRetriever = null ][, int $checkMode = Constraint::CHECK_MODE_NORMAL ]) : mixed
Parameters
- $schemaStorage : SchemaStorage = null
- $uriRetriever : UriRetrieverInterface = null
- $checkMode : int = Constraint::CHECK_MODE_NORMAL
addConfig()
Enable checkMode flags
public
addConfig(int $options) : mixed
Parameters
- $options : int
createInstanceFor()
Create a constraint instance for the given constraint name.
public
createInstanceFor(string $constraintName) : ConstraintInterface|ObjectConstraint
Parameters
- $constraintName : string
Tags
Return values
ConstraintInterface|ObjectConstraintgetConfig()
Get checkMode option
public
getConfig([int $options = null ]) : int
Parameters
- $options : int = null
-
Options to get, if null then return entire bitmask
Return values
intgetErrorContext()
Get the error context
public
getErrorContext() : string
Return values
stringgetSchemaStorage()
public
getSchemaStorage() : mixed
getTypeCheck()
public
getTypeCheck() : mixed
getUriRetriever()
public
getUriRetriever() : UriRetrieverInterface
Return values
UriRetrieverInterfaceremoveConfig()
Disable checkMode flags
public
removeConfig(int $options) : mixed
Parameters
- $options : int
setConfig()
Set config values
public
setConfig([int $checkMode = Constraint::CHECK_MODE_NORMAL ]) : mixed
Parameters
- $checkMode : int = Constraint::CHECK_MODE_NORMAL
-
Set checkMode options - does not preserve existing flags
setConstraintClass()
public
setConstraintClass(string $name, string $class) : Factory
Parameters
- $name : string
- $class : string
Return values
FactorysetErrorContext()
Set the error context
public
setErrorContext(mixed $errorContext) : mixed
Parameters
- $errorContext : mixed