» API Reference » ORM\Helper
ORM\Helper
Table of Contents
Abstract
Methods
ORM\Helper::first
public static function first(array $array, mixed $default = null): mixed
Get the first element of $array
Returns $default if the array is empty.
Static |
|
This method is static. |
Returns |
mixed |
|
Parameters
Parameter |
Type |
Description |
$array |
array |
|
$default |
mixed |
|
ORM\Helper::first
↑ top
ORM\Helper::getKey
public static function getKey(
array $reference,
\ORM\Entity $entity,
bool $allowEmpty = true,
): array|null
Get the key (defined by $referenced) from $entity
Reference defines the mapping of attributes in $entity to attributes in the referenced object.
Example: $entity is an Article and the ‘userId’ references the ‘id’ of the user. Then $reference should be
['userId' => 'id']
and the result will be ['id' => 23]
Parameters
Parameter |
Type |
Description |
$reference |
array |
|
$entity |
ORM\Entity |
|
$allowEmpty |
bool |
|
ORM\Helper::getKey
↑ top
ORM\Helper::getUniqueKeys
public static function getUniqueKeys(
array $reference,
\ORM\Entity $entities,
): array|false
Get a unique list of keys (defined by $reference) from $entities
Static |
|
This method is static. |
Returns |
array|false |
|
Parameters
Parameter |
Type |
Description |
$reference |
array |
|
$entities |
ORM\Entity |
|
See Also:
ORM\Helper::getUniqueKeys
↑ top
ORM\Helper::groupBy
public static function groupBy(array $array, mixed $retriever): mixed
Static |
|
This method is static. |
Returns |
mixed |
|
Parameters
Parameter |
Type |
Description |
$array |
array |
|
$retriever |
mixed |
|
ORM\Helper::groupBy
↑ top
ORM\Helper::keyBy
public static function keyBy(array $array, mixed $retriever): array|false
Create an associative array where the key
Static |
|
This method is static. |
Returns |
array|false |
|
Parameters
Parameter |
Type |
Description |
$array |
array |
|
$retriever |
mixed |
|
ORM\Helper::keyBy
↑ top
ORM\Helper::only
public static function only(array $array, array $keys): mixed
Static |
|
This method is static. |
Returns |
mixed |
|
Parameters
Parameter |
Type |
Description |
$array |
array |
|
$keys |
array |
|
ORM\Helper::only
↑ top
ORM\Helper::pluck
public static function pluck(array $array, mixed $retriever): mixed
Static |
|
This method is static. |
Returns |
mixed |
|
Parameters
Parameter |
Type |
Description |
$array |
array |
|
$retriever |
mixed |
|
ORM\Helper::pluck
↑ top
ORM\Helper::shortName
public static function shortName(string $class): string
Gets the short name of a class without creating a Reflection
Static |
|
This method is static. |
Returns |
string |
|
Parameters
Parameter |
Type |
Description |
$class |
string |
|
ORM\Helper::shortName
↑ top
ORM\Helper::traitUsesRecursive
public static function traitUsesRecursive(
string $class,
bool $withParents = true,
): string[]
Get all traits used by the class and it’s parents.
Iterates recursively through traits to get traits used by traits.
Static |
|
This method is static. |
Returns |
string[] |
|
Parameters
Parameter |
Type |
Description |
$class |
string |
|
$withParents |
bool |
|
ORM\Helper::traitUsesRecursive
↑ top
ORM\Helper::uniqueArrays
public static function uniqueArrays(array[] $array): array
Make an array of arrays unique
Static |
|
This method is static. |
Returns |
array |
|
Parameters
Parameter |
Type |
Description |
$array |
array[] |
|
ORM\Helper::uniqueArrays
↑ top