Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
UArrayModels Class Reference

Ubiquity\utils\models$UArrayModels This class is part of Ubiquity. More...

Static Public Member Functions

static sort (array $array, callable $callback)
 Returns a sorted array using a user defined comparison function.
 
static groupsBy (array $objects, array $gbCallbacks, ?callable $lineCallback=null, ?bool $sort=null)
 Groups an array using an array of user defined comparison functions.
 
static groupBy (array $objects, callable $gbCallback, ?callable $lineCallback=null, ?bool $sort=null)
 Groups an array using a user defined comparison function.
 
static asKeyValues (array $objects, $keyFunction=NULL, $valueFunction=NULL)
 Returns an associative array of key/values from an array of objects.
 
static find (?array $objects, callable $callback)
 Finds and returns the first occurrence of the array satisfying the callback.
 
static findBy (?array $objects, $value, string $property='id')
 Finds and returns the first occurrence of the array using one of the objects properties.
 
static findById (?array $objects, $idValue)
 Finds and returns the first occurrence of the array using the objects id.
 
static contains (?array $objects, callable $callback)
 Checks if an object exist in an array of objects satisfying the callback.
 
static containsBy (?array $objects, object $object, string $property='id')
 Checks if an object exist in an array of objects using one of the object property.
 
static containsById (?array $objects, object $object)
 Checks if an object exist in an array of objects using the object id.
 
static remove (?array $objects, callable $callback)
 Removes the first occurrence of the array satisfying the callback.
 
static removeBy (?array $objects, object $object, string $property='id')
 Removes an object from an array of objects using one of its properties.
 
static removeAllBy (?array $objects, object $object, string $property='id')
 Removes objects from an array of objects using one of their properties.
 
static compute (?array $objects, callable $callable, callable $computeCall)
 
static computeSumProperty (?array $objects, string $propertyName)
 
static computeSum (?array $objects, callable $callable)
 
static removeAll (?array $objects, callable $callback)
 Removes all the occurrences of the array satisfying the callback.
 
static asArray (array $objects)
 
static asJson (array $objects, int $options=0)
 
static asArrayProperties (array $objects, array $properties)
 
static asJsonProperties (array $objects, array $properties, int $options=0)
 

Static Private Member Functions

static getAccessors ($properties, $prefix='get')
 
static callFunction ($object, $callback)
 

Detailed Description

Ubiquity\utils\models$UArrayModels This class is part of Ubiquity.

Author
jc
Version
1.0.2

Definition at line 14 of file UArrayModels.php.

Member Function Documentation

◆ asArray()

static asArray ( array  $objects)
static
Parameters
array$objects
Returns
array

Definition at line 301 of file UArrayModels.php.

◆ asArrayProperties()

static asArrayProperties ( array  $objects,
array  $properties 
)
static
Parameters
array$objects
array$properties
Returns
array

Definition at line 327 of file UArrayModels.php.

◆ asJson()

static asJson ( array  $objects,
int  $options = 0 
)
static
Parameters
array$objects
int$options
Returns
string

Definition at line 314 of file UArrayModels.php.

◆ asJsonProperties()

static asJsonProperties ( array  $objects,
array  $properties,
int  $options = 0 
)
static
Parameters
array$objects
array$properties
int$options
Returns
string

Definition at line 346 of file UArrayModels.php.

◆ asKeyValues()

static asKeyValues ( array  $objects,
  $keyFunction = NULL,
  $valueFunction = NULL 
)
static

Returns an associative array of key/values from an array of objects.

Parameters
array$objects
?string|callable$keyFunction
?string|callable$valueFunction
Returns
array

Definition at line 83 of file UArrayModels.php.

◆ callFunction()

static callFunction (   $object,
  $callback 
)
staticprivate
Parameters
$object
$callback
Returns
false|mixed

Definition at line 364 of file UArrayModels.php.

◆ compute()

static compute ( ?array  $objects,
callable  $callable,
callable  $computeCall 
)
static

Definition at line 259 of file UArrayModels.php.

◆ computeSum()

static computeSum ( ?array  $objects,
callable  $callable 
)
static

Definition at line 274 of file UArrayModels.php.

◆ computeSumProperty()

static computeSumProperty ( ?array  $objects,
string  $propertyName 
)
static

Definition at line 269 of file UArrayModels.php.

◆ contains()

static contains ( ?array  $objects,
callable  $callback 
)
static

Checks if an object exist in an array of objects satisfying the callback.

Parameters
array$objects
callable$callback
Returns
bool

Definition at line 159 of file UArrayModels.php.

◆ containsBy()

static containsBy ( ?array  $objects,
object  $object,
string  $property = 'id' 
)
static

Checks if an object exist in an array of objects using one of the object property.

Parameters
array$objects
object$object
string$property
Returns
bool

Definition at line 171 of file UArrayModels.php.

◆ containsById()

static containsById ( ?array  $objects,
object  $object 
)
static

Checks if an object exist in an array of objects using the object id.

Parameters
array$objects
object$object
Returns
bool

Definition at line 187 of file UArrayModels.php.

◆ find()

static find ( ?array  $objects,
callable  $callback 
)
static

Finds and returns the first occurrence of the array satisfying the callback.

Parameters
array | null$objects
callable$callback
Returns
mixed|null

Definition at line 106 of file UArrayModels.php.

◆ findBy()

static findBy ( ?array  $objects,
  $value,
string  $property = 'id' 
)
static

Finds and returns the first occurrence of the array using one of the objects properties.

Parameters
array$objects
mixed$value
string$propertydefault the id property
Returns
mixed|null

Definition at line 124 of file UArrayModels.php.

◆ findById()

static findById ( ?array  $objects,
  $idValue 
)
static

Finds and returns the first occurrence of the array using the objects id.

Parameters
array$objects
mixed$idValue
Returns
NULL|mixed|NULL

Definition at line 144 of file UArrayModels.php.

◆ getAccessors()

static getAccessors (   $properties,
  $prefix = 'get' 
)
staticprivate

Definition at line 350 of file UArrayModels.php.

◆ groupBy()

static groupBy ( array  $objects,
callable  $gbCallback,
?callable  $lineCallback = null,
?bool  $sort = null 
)
static

Groups an array using a user defined comparison function.

Parameters
array$objects
callable$gbCallback
callable | null$lineCallback
bool | null$sort
Returns
array

Definition at line 55 of file UArrayModels.php.

◆ groupsBy()

static groupsBy ( array  $objects,
array  $gbCallbacks,
?callable  $lineCallback = null,
?bool  $sort = null 
)
static

Groups an array using an array of user defined comparison functions.

Parameters
array$objects
array$gbCallbacks
callable | null$lineCallback
bool | null$sort
Returns
array

Definition at line 34 of file UArrayModels.php.

◆ remove()

static remove ( ?array  $objects,
callable  $callback 
)
static

Removes the first occurrence of the array satisfying the callback.

Parameters
array | null$objects
callable$callback
Returns
array

Definition at line 202 of file UArrayModels.php.

◆ removeAll()

static removeAll ( ?array  $objects,
callable  $callback 
)
static

Removes all the occurrences of the array satisfying the callback.

Parameters
array | null$objects
callable$callback
Returns
array

Definition at line 284 of file UArrayModels.php.

◆ removeAllBy()

static removeAllBy ( ?array  $objects,
object  $object,
string  $property = 'id' 
)
static

Removes objects from an array of objects using one of their properties.

Parameters
array$objects
object$object
string$propertydefault the id property
Returns
?array

Definition at line 241 of file UArrayModels.php.

◆ removeBy()

static removeBy ( ?array  $objects,
object  $object,
string  $property = 'id' 
)
static

Removes an object from an array of objects using one of its properties.

Parameters
array$objects
object$object
string$propertydefault the id property
Returns
?array

Definition at line 219 of file UArrayModels.php.

◆ sort()

static sort ( array  $array,
callable  $callback 
)
static

Returns a sorted array using a user defined comparison function.

Parameters
array$array
callable$callback
Returns
array

Definition at line 21 of file UArrayModels.php.


The documentation for this class was generated from the following file: