PAR - PHP Additional Repository

Values
in package

FinalYes

Helper class with methods to assist in value handling.

Table of Contents

Methods

equals()  : bool
Determines if two values should be considered equal.
equalsNoneIn()  : bool
Determines if a value should be considered equal to __none__ of the items in the list of other values.
equalsNoneOf()  : bool
Determines if a value should be considered equal to __none__ of the other values.
equalsOneIn()  : bool
Determines if a value should be considered equal to __one__ of the items in the list of other values.
equalsOneOf()  : bool
Determines if a value should be considered equal to __one__ or __more__ other values.

Methods

equals()

Determines if two values should be considered equal.

public static equals(mixed $value, mixed $otherValue) : bool
  • If $value implements \Par\Core\ObjectEquality then $value->equals($otherValue) is used.
  • If $otherValue implements \Par\Core\ObjectEquality then $otherValue->equals($value) is used.
  • When both values are instances of \DateTime $value == $otherValue is used.
  • When both values are instances of \DateTimeImmutable $value == $otherValue is used.
  • Otherwise a strict comparison ($value === $otherValue) is used.

Usage:

if (Values::equals($a, $b)) {
    // When equal
}
Parameters
$value : mixed

The value to test

$otherValue : mixed

The other value with which to compare

Tags
psalm-mutation-free
Return values
bool

True if both values should be considered equal

equalsNoneIn()

Determines if a value should be considered equal to __none__ of the items in the list of other values.

public static equalsNoneIn(mixed $value, iterable<string|int, mixed> $otherValues) : bool

Usage:

if (Values::equalsNoneIn($a, [$b, $c])) {
    // When not equal to $b and $c
}
Parameters
$value : mixed

The value to test

$otherValues : iterable<string|int, mixed>

The list of other values with which to compare

Tags
see
Values::equals
psalm-mutation-free
Return values
bool

True if value should be considered equal to none of the items in the list of other values

equalsNoneOf()

Determines if a value should be considered equal to __none__ of the other values.

public static equalsNoneOf(mixed $value, mixed ...$otherValues) : bool

Usage:

if (Values::equalsNoneOf($a, $b, $c)) {
    // When not equal to $b and $c
}
Parameters
$value : mixed

The value to test

$otherValues : mixed

The other values with which to compare

Tags
psalm-mutation-free
see
Values::equals
Return values
bool

True if value should be considered equal to none of the other values

equalsOneIn()

Determines if a value should be considered equal to __one__ of the items in the list of other values.

public static equalsOneIn(mixed $value, iterable<string|int, mixed> $otherValues) : bool

Usage:

if (Values::equalsOneIn($a, [$b, $c])) {
    // When equal to $b or $c
}
Parameters
$value : mixed

The value to test

$otherValues : iterable<string|int, mixed>

The list of other values with which to compare

Tags
see
Values::equals
psalm-mutation-free
Return values
bool

True if value should be considered equal to one of the items in the list of other values

equalsOneOf()

Determines if a value should be considered equal to __one__ or __more__ other values.

public static equalsOneOf(mixed $value, mixed ...$otherValues) : bool

Usage:

if (Values::equalsOneOf($a, $b, $c)) {
// When not equal to $b or $c
}
Parameters
$value : mixed

The value to test

$otherValues : mixed

The other values with which to compare

Tags
psalm-mutation-free
see
Values::equals
Return values
bool

True if value should be considered equal to one or more of the other values


        
On this page

Search results