[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/data/src/ -> DataSet.php (summary)

Part of the Joomla Framework Data Package

Copyright: Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
License: GNU General Public License version 2 or later; see LICENSE
File Size: 613 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

DataSet:: (24 methods):
  __construct()
  __call()
  __get()
  __isset()
  __set()
  __unset()
  getObjectsKeys()
  toArray()
  count()
  clear()
  current()
  dump()
  jsonSerialize()
  key()
  keys()
  walk()
  next()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()
  rewind()
  valid()
  initialise()


Class: DataSet  - X-Ref

DataSet is a collection class that allows the developer to operate on a set of DataObjects as if they were in a typical PHP array.

__construct(array $objects = [])   X-Ref
The class constructor.

param: DataObject[]  $objects  An array of DataObject objects to bind to the data set.

__call($method, $arguments = [])   X-Ref
The magic call method is used to call object methods using the iterator.

Example: $array = $objectList->foo('bar');

The object list will iterate over its objects and see if each object has a callable 'foo' method.
If so, it will pass the argument list and assemble any return values. If an object does not have
a callable method no return value is recorded.
The keys of the objects and the result array are maintained.

param: string  $method     The name of the method called.
param: array   $arguments  The arguments of the method called.
return: array   An array of values returned by the methods called on the objects in the data set.

__get($property)   X-Ref
The magic get method is used to get a list of properties from the objects in the data set.

Example: $array = $dataSet->foo;

This will return a column of the values of the 'foo' property in all the objects
(or values determined by custom property setters in the individual DataObject's).
The result array will contain an entry for each object in the list (compared to __call which may not).
The keys of the objects and the result array are maintained.

param: string  $property  The name of the data property.
return: array  An associative array of the values.

__isset($property)   X-Ref
The magic isset method is used to check the state of an object property using the iterator.

Example: $array = isset($objectList->foo);

param: string  $property  The name of the property.
return: boolean  True if the property is set in any of the objects in the data set.

__set($property, $value)   X-Ref
The magic set method is used to set an object property using the iterator.

Example: $objectList->foo = 'bar';

This will set the 'foo' property to 'bar' in all of the objects
(or a value determined by custom property setters in the DataObject).

param: string  $property  The name of the property.
param: mixed   $value     The value to give the data property.
return: void

__unset($property)   X-Ref
The magic unset method is used to unset an object property using the iterator.

Example: unset($objectList->foo);

This will unset all of the 'foo' properties in the list of DataObject's.

param: string  $property  The name of the property.
return: void

getObjectsKeys($type = 'all')   X-Ref
Gets an array of keys, existing in objects

param: string  $type  Selection type 'all' or 'common'
return: array   Array of keys

toArray($associative = true, ...$keys)   X-Ref
Gets all objects as an array

param: boolean  $associative  Option to set return mode: associative or numeric array.
param: string   ...$keys      Unlimited optional property names to extract from objects.
return: array  Returns an array according to defined options.

count()   X-Ref
Gets the number of data objects in the set.

return: integer  The number of objects.

clear()   X-Ref
Clears the objects in the data set.

return: DataSet  Returns itself to allow chaining.

current()   X-Ref
Get the current data object in the set.

return: DataObject|false  The current object, or false if the array is empty or the pointer is beyond the end of the elements.

dump($depth = 3, \SplObjectStorage $dumped = null)   X-Ref
Dumps the data object in the set, recursively if appropriate.

param: integer            $depth   The maximum depth of recursion (default = 3).
param: \SplObjectStorage  $dumped  An array of already serialized objects that is used to avoid infinite loops.
return: array  An associative array of the data objects in the set, dumped as a simple PHP stdClass object.

jsonSerialize()   X-Ref
Gets the data set in a form that can be serialised to JSON format.

Note that this method will not return an associative array, otherwise it would be encoded into an object.
JSON decoders do not consistently maintain the order of associative keys, whereas they do maintain the order of arrays.

return: array

key()   X-Ref
Gets the key of the current object in the iterator.

return: integer|false  The object key on success; false on failure.

keys()   X-Ref
Gets the array of keys for all the objects in the iterator (emulates array_keys).

return: array  The array of keys

walk(callable $funcname)   X-Ref
Applies a function to every object in the set (emulates array_walk).

param: callable  $funcname  Callback function.
return: boolean

next()   X-Ref
Advances the iterator to the next object in the iterator.

return: void

offsetExists($offset)   X-Ref
Checks whether an offset exists in the iterator.

param: mixed  $offset  The object offset.
return: boolean

offsetGet($offset)   X-Ref
Gets an offset in the iterator.

param: mixed  $offset  The object offset.
return: DataObject|null

offsetSet($offset, $object)   X-Ref
Sets an offset in the iterator.

param: mixed       $offset  The object offset.
param: DataObject  $object  The object object.
return: void

offsetUnset($offset)   X-Ref
Unsets an offset in the iterator.

param: mixed  $offset  The object offset.
return: void

rewind()   X-Ref
Rewinds the iterator to the first object.

return: void

valid()   X-Ref
Validates the iterator.

return: boolean

initialise(array $input = [])   X-Ref
Initialises the list with an array of objects.

param: array  $input  An array of objects.
return: void



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer