Class JDataSet

Description

Implements interfaces:

  • JDataDumpable
  • ArrayAccess (internal interface)
  • Countable (internal interface)
  • Iterator (internal interface)

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

  • since: 12.3

Located in /libraries/joomla/data/set.php (line 20)


	
			
Method Summary
 JDataSet __construct ([array $objects = array()])
 integer count ()
 array dump ([integer $depth = 3], [SplObjectStorage $dumped = null])
 array jsonSerialize ([mixed $serialized = null])
 scalar key ()
 array keys ()
 void next ()
 boolean offsetExists (mixed $offset)
 JData offsetGet (mixed $offset)
 void offsetSet (mixed $offset, JData $object)
 void offsetUnset (mixed $offset)
 void rewind ()
 boolean valid ()
 array __call (string $method, [array $arguments = array()])
 array __get (string $property)
 boolean __isset (string $property)
 void __set (string $property, mixed $value)
 void __unset (string $property)
Methods
Constructor __construct (line 46)

The class constructor.

  • since: 12.3
  • throws: InvalidArgumentException if an object is not an instance of JData.
  • access: public
JDataSet __construct ([array $objects = array()])
  • array $objects: An array of JData objects to bind to the data set.
clear (line 211)

Clears the objects in the data set.

  • return: Returns itself to allow chaining.
  • since: 12.3
  • access: public
JDataSet clear ()
count (line 199)

Gets the number of data objects in the set.

  • return: The number of objects.
  • since: 12.3
  • access: public
integer count ()

Implementation of:
Countable::count
current (line 226)

Get the current data object in the set.

  • return: The current object, or false if the array is empty or the pointer is beyond the end of the elements.
  • since: 12.3
  • access: public
JData current ()

Implementation of:
Iterator::current
dump (line 244)

Dumps the data object in the set, recursively if appropriate.

  • return: An associative array of the date objects in the set, dumped as a simple PHP stdClass object.
  • see: JData::dump()
  • since: 12.3
  • access: public
array dump ([integer $depth = 3], [SplObjectStorage $dumped = null])
  • integer $depth: The maximum depth of recursion (default = 3). For example, a depth of 0 will return a stdClass with all the properties in native form. A depth of 1 will recurse into the first level of properties only.
  • SplObjectStorage $dumped: An array of already serialized objects that is used to avoid infinite loops.

Implementation of:
JDataDumpable::dump()
Dumps the object properties into a stdClass object, recursively if appropriate.
jsonSerialize (line 283)

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: An array that can be serialised by json_encode().
  • since: 12.3
  • access: public
array jsonSerialize ([mixed $serialized = null])
  • mixed $serialized: An array of objects that have already been serialized that is used to infinite loops (null on first call).
key (line 312)

Gets the key of the current object in the iterator.

  • return: The object key on success; null on failure.
  • since: 12.3
  • access: public
scalar key ()

Implementation of:
Iterator::key
keys (line 324)

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

  • return: The array of keys
  • since: 12.3
  • access: public
array keys ()
next (line 336)

Advances the iterator to the next object in the iterator.

  • since: 12.3
  • access: public
void next ()

Implementation of:
Iterator::next
offsetExists (line 375)

Checks whether an offset exists in the iterator.

  • return: True if the object exists, false otherwise.
  • since: 12.3
  • access: public
boolean offsetExists (mixed $offset)
  • mixed $offset: The object offset.

Implementation of:
ArrayAccess::offsetExists
offsetGet (line 389)

Gets an offset in the iterator.

  • return: The object if it exists, null otherwise.
  • since: 12.3
  • access: public
JData offsetGet (mixed $offset)
  • mixed $offset: The object offset.

Implementation of:
ArrayAccess::offsetGet
offsetSet (line 405)

Sets an offset in the iterator.

  • since: 12.3
  • throws: InvalidArgumentException if an object is not an instance of JData.
  • access: public
void offsetSet (mixed $offset, JData $object)
  • mixed $offset: The object offset.
  • JData $object: The object object.

Implementation of:
ArrayAccess::offsetSet
offsetUnset (line 426)

Unsets an offset in the iterator.

  • since: 12.3
  • access: public
void offsetUnset (mixed $offset)
  • mixed $offset: The object offset.

Implementation of:
ArrayAccess::offsetUnset
rewind (line 464)

Rewinds the iterator to the first object.

  • since: 12.3
  • access: public
void rewind ()

Implementation of:
Iterator::rewind
valid (line 485)

Validates the iterator.

  • return: True if valid, false otherwise.
  • since: 12.3
  • access: public
boolean valid ()

Implementation of:
Iterator::valid
__call (line 69)

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.

  • return: An array of values returned by the methods called on the objects in the data set.
  • since: 12.3
  • access: public
array __call (string $method, [array $arguments = array()])
  • string $method: The name of the method called.
  • array $arguments: The arguments of the method called.
__get (line 106)

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 JData'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.

  • return: An associative array of the values.
  • since: 12.3
  • access: public
array __get (string $property)
  • string $property: The name of the data property.
__isset (line 131)

The magic isset method is used to check the state of an object property using the iterator.

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

  • return: True if the property is set in any of the objects in the data set.
  • since: 12.3
  • access: public
boolean __isset (string $property)
  • string $property: The name of the property.
__set (line 160)

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 JData).

  • since: 12.3
  • access: public
void __set (string $property, mixed $value)
  • string $property: The name of the property.
  • mixed $value: The value to give the data property.
__unset (line 183)

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 JData's.

  • since: 12.3
  • access: public
void __unset (string $property)
  • string $property: The name of the property.

Documentation generated on Tue, 19 Nov 2013 15:12:56 +0100 by phpDocumentor 1.4.3