class GetterMetadata extends MemberMetadata

Stores all metadata needed for validating a class property via its getter method.

A property getter is any method that is equal to the property's name, prefixed with either "get" or "is". That method will be used to access the property's value.

The getter will be invoked by reflection, so the access of private and protected getters is supported.

This class supports serialization and cloning.

Properties

Constraint[] $constraints from GenericMetadata
array $constraintsByGroup from GenericMetadata
int $cascadingStrategy The strategy for cascading objects. from GenericMetadata
int $traversalStrategy The strategy for traversing traversable objects. from GenericMetadata
$class from MemberMetadata
$name from MemberMetadata
$property from MemberMetadata

Methods

string[]
__sleep()

Returns the names of the properties that should be serialized.

__clone()

Clones this object.

$this
addConstraint(Constraint $constraint)

Adds a constraint.

$this
addConstraints(array $constraints)

Adds an list of constraints.

getConstraints()

Returns all constraints of this element.

bool
hasConstraints()

Returns whether this element has any constraints.

findConstraints(string $group)

Returns all constraints for a given validation group.

int
getCascadingStrategy()

Returns the strategy for cascading objects.

int
getTraversalStrategy()

Returns the strategy for traversing traversable objects.

__construct(string $class, string $property, string $method = null)

No description

string
getName()

Returns the name of the member.

getClassName()

{@inheritdoc}

string
getPropertyName()

Returns the name of the property.

bool
isPublic(object|string $objectOrClassName)

Returns whether this member is public.

bool
isProtected(object|string $objectOrClassName)

Returns whether this member is protected.

bool
isPrivate(object|string $objectOrClassName)

Returns whether this member is private.

getReflectionMember(object|string $objectOrClassName)

Returns the reflection instance for accessing the member's value.

mixed
getPropertyValue($object)

Extracts the value of the property from the given container.

Details

in MemberMetadata at line line 89
string[] __sleep()

Returns the names of the properties that should be serialized.

Return Value

string[]

in GenericMetadata at line line 94
__clone()

Clones this object.

in MemberMetadata at line line 72
$this addConstraint(Constraint $constraint)

Adds a constraint.

If the constraint {@link Valid} is added, the cascading strategy will be changed to {@link CascadingStrategy::CASCADE}. Depending on the $traverse property of that constraint, the traversal strategy will be set to one of the following:

  • {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
  • {@link TraversalStrategy::NONE} if $traverse is disabled

Parameters

Constraint $constraint

Return Value

$this

Exceptions

ConstraintDefinitionException When trying to add the {@link Traverse} constraint

in GenericMetadata at line line 160
$this addConstraints(array $constraints)

Adds an list of constraints.

Parameters

array $constraints The constraints to add

Return Value

$this

in GenericMetadata at line line 172
Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

in GenericMetadata at line line 182
bool hasConstraints()

Returns whether this element has any constraints.

Return Value

bool

in GenericMetadata at line line 192
Constraint[] findConstraints(string $group)

Returns all constraints for a given validation group.

Parameters

string $group The validation group

Return Value

Constraint[] A list of constraint instances

in GenericMetadata at line line 202
int getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

int The cascading strategy

in GenericMetadata at line line 210
int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

int The traversal strategy

at line line 42
__construct(string $class, string $property, string $method = null)

Parameters

string $class The name of the class this member is defined on
string $property The property the member belongs to
string $method The method that is called to retrieve the value being validated (null for auto-detection)

Exceptions

ValidatorException

in MemberMetadata at line line 103
string getName()

Returns the name of the member.

Return Value

string

in MemberMetadata at line line 111
getClassName()

{@inheritdoc}

in MemberMetadata at line line 119
string getPropertyName()

Returns the name of the property.

Return Value

string The property name

in MemberMetadata at line line 131
bool isPublic(object|string $objectOrClassName)

Returns whether this member is public.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line line 143
bool isProtected(object|string $objectOrClassName)

Returns whether this member is protected.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line line 155
bool isPrivate(object|string $objectOrClassName)

Returns whether this member is private.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line line 167
ReflectionMethod|ReflectionProperty getReflectionMember(object|string $objectOrClassName)

Returns the reflection instance for accessing the member's value.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

ReflectionMethod|ReflectionProperty The reflection instance

at line line 68
mixed getPropertyValue($object)

Extracts the value of the property from the given container.

Parameters

$object

Return Value

mixed The value of the property