class Length extends StringComparator (View source)

Check if the length of the input matches the min and max values.

If min and max are equal, the count must match that value regardless of the inclusive flag.

Traits

Methods

__construct(int $min = null, int $max = null, bool $inclusive = true)

No description

bool
__invoke(mixed $value)

Compare the input value against the comparator.

static Length
between(int $min, int $max, bool $inclusive = true)

Length must be between the given sizes.

bool
check(mixed $value)

Compare the input string against the comparator.

bool
checkString(string $value)

Compare the input string against the comparator.

static Length
equal(int $size)

Length must be equal to the given size.

static Length
make(int $min = null, int $max = null, bool $inclusive = true)

No description

static Length
max(int $max, bool $inclusive = true)

Length must be less than or equal to the given size.

static Length
min(int $min, bool $inclusive = true)

Length must be greater than or equal to the given size.

string
resolveStringInput(mixed $value)

No description

Details

__construct(int $min = null, int $max = null, bool $inclusive = true)

No description

Parameters

int $min

Minimum length. Null means no minimum.

int $max

Maximum length. Null means no maximum.

bool $inclusive

Whether to include the minimum and maximum in the comparison (default: true)

final bool __invoke(mixed $value)

Compare the input value against the comparator.

Parameters

mixed $value

Return Value

bool

static Length between(int $min, int $max, bool $inclusive = true)

Length must be between the given sizes.

Parameters

int $min

Minimum size

int $max

Maximum size

bool $inclusive

Whether to include the minimum and maximum in the comparison (default: true)

Return Value

Length

final bool check(mixed $value)

Compare the input string against the comparator.

Parameters

mixed $value

Return Value

bool

protected bool checkString(string $value)

Compare the input string against the comparator.

Parameters

string $value

Return Value

bool

static Length equal(int $size)

Length must be equal to the given size.

Parameters

int $size

Size to compare to

Return Value

Length

static Length make(int $min = null, int $max = null, bool $inclusive = true)

No description

Parameters

int $min

Minimum length. Null means no minimum.

int $max

Maximum length. Null means no maximum.

bool $inclusive

Whether to include the minimum and maximum in the comparison (default: true)

Return Value

Length

static Length max(int $max, bool $inclusive = true)

Length must be less than or equal to the given size.

Parameters

int $max

Maximum size

bool $inclusive

Whether to include the maximum in the comparison (default: true)

Return Value

Length

static Length min(int $min, bool $inclusive = true)

Length must be greater than or equal to the given size.

Parameters

int $min

Minimum size

bool $inclusive

Whether to include the minimum in the comparison (default: true)

Return Value

Length

protected string resolveStringInput(mixed $value)

No description

Parameters

mixed $value

Return Value

string