ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilBuddySystemArrayCollection Class Reference

Class ilBuddySystemArrayCollection A collection which contains all entries of a buddy list. More...

+ Inheritance diagram for ilBuddySystemArrayCollection:
+ Collaboration diagram for ilBuddySystemArrayCollection:

Public Member Functions

 __construct (array $elements=array())
 
 getIterator ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ()
 
 add ($element)
 Adds an element at the end of the collection.
Parameters
mixed$element
More...
 
 remove ($key)
 
Parameters
string | integer$keyThe index of the element to remove.
Exceptions
InvalidArgumentException
More...
 
 removeElement ($element)
 
Parameters
mixed$elementThe element to remove.
Exceptions
InvalidArgumentException
More...
 
 containsKey ($key)
 
Parameters
string | integer$keyThe index to check for.
Returns
boolean true if the collection contains the element, false otherwise.
More...
 
 getKey ($element)
 
 clear ()
 Clears the list. More...
 
 contains ($element)
 
Parameters
mixed$element
Returns
boolean true if the collection contains the element, false otherwise.
More...
 
 get ($key)
 
Parameters
string | integer$keyThe index of the element to get.
Returns
mixed
More...
 
 set ($key, $value)
 
Parameters
string  | integer$keyThe index of the element to set.
mixed$value
More...
 
 isEmpty ()
 
Returns
boolean true if the collection is empty, false otherwise.
More...
 
 getKeys ()
 Gets all indices of the collection.
Returns
array The indices of the collection, in the order of the corresponding elements in the collection.
More...
 
 getValues ()
 Gets all values of the collection.
Returns
array The values of all elements in the collection, in the order they appear in the collection.
More...
 
 filter (Closure $p)
 Returns all the elements of this collection that satisfy the predicate $callable.
Parameters
Closure$closure
Returns
ilBuddySystemCollection
More...
 
 slice ($offset, $length=null)
 Extracts a slice of $length elements starting at position $offset from the Collection.If $length is null it returns all elements from $offset to the end of the Collection. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.

Parameters
int$offsetThe offset to start from.
int | null$lengthThe maximum number of elements to return, or null for no limit.
Returns
ilBuddySystemCollection
More...
 
 toArray ()
 

Private Attributes

 $elements = array()
 

Detailed Description

Class ilBuddySystemArrayCollection A collection which contains all entries of a buddy list.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 11 of file class.ilBuddySystemArrayCollection.php.

Constructor & Destructor Documentation

◆ __construct()

ilBuddySystemArrayCollection::__construct ( array  $elements = array())
Parameters
array$elements

Definition at line 21 of file class.ilBuddySystemArrayCollection.php.

References $elements.

22  {
23  $this->elements = $elements;
24  }

Member Function Documentation

◆ add()

ilBuddySystemArrayCollection::add (   $element)

Adds an element at the end of the collection.

Parameters
mixed$element

Implements ilBuddySystemCollection.

Definition at line 83 of file class.ilBuddySystemArrayCollection.php.

Referenced by offsetSet().

84  {
85  $this->elements[] = $element;
86  }
+ Here is the caller graph for this function:

◆ clear()

ilBuddySystemArrayCollection::clear ( )

Clears the list.

Implements ilBuddySystemCollection.

Definition at line 133 of file class.ilBuddySystemArrayCollection.php.

References array.

134  {
135  $this->elements = array();
136  }
Create styles array
The data for the language used.

◆ contains()

ilBuddySystemArrayCollection::contains (   $element)

Parameters
mixed$element
Returns
boolean true if the collection contains the element, false otherwise.

Implements ilBuddySystemCollection.

Definition at line 141 of file class.ilBuddySystemArrayCollection.php.

142  {
143  return in_array($element, $this->elements, true);
144  }

◆ containsKey()

ilBuddySystemArrayCollection::containsKey (   $key)

Parameters
string | integer$keyThe index to check for.
Returns
boolean true if the collection contains the element, false otherwise.

Implements ilBuddySystemCollection.

Definition at line 116 of file class.ilBuddySystemArrayCollection.php.

Referenced by offsetExists().

117  {
118  return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
119  }
+ Here is the caller graph for this function:

◆ count()

ilBuddySystemArrayCollection::count ( )

Definition at line 75 of file class.ilBuddySystemArrayCollection.php.

76  {
77  return count($this->elements);
78  }

◆ filter()

ilBuddySystemArrayCollection::filter ( Closure  $p)

Returns all the elements of this collection that satisfy the predicate $callable.

Parameters
Closure$closure
Returns
ilBuddySystemCollection

Implements ilBuddySystemCollection.

Definition at line 189 of file class.ilBuddySystemArrayCollection.php.

190  {
191  return new static(array_filter($this->elements, $p));
192  }

◆ get()

ilBuddySystemArrayCollection::get (   $key)

Parameters
string | integer$keyThe index of the element to get.
Returns
mixed

Implements ilBuddySystemCollection.

Definition at line 149 of file class.ilBuddySystemArrayCollection.php.

150  {
151  return isset($this->elements[$key]) ? $this->elements[$key] : null;
152  }

◆ getIterator()

ilBuddySystemArrayCollection::getIterator ( )

Definition at line 29 of file class.ilBuddySystemArrayCollection.php.

30  {
31  return new ArrayIterator($this->elements);
32  }

◆ getKey()

ilBuddySystemArrayCollection::getKey (   $element)
Parameters
mixed$elementThe element
Returns
string|integer The index of the element.

Implements ilBuddySystemCollection.

Definition at line 125 of file class.ilBuddySystemArrayCollection.php.

126  {
127  return array_search($element, $this->elements, true);
128  }

◆ getKeys()

ilBuddySystemArrayCollection::getKeys ( )

Gets all indices of the collection.

Returns
array The indices of the collection, in the order of the corresponding elements in the collection.

Implements ilBuddySystemCollection.

Definition at line 173 of file class.ilBuddySystemArrayCollection.php.

174  {
175  return array_keys($this->elements);
176  }

◆ getValues()

ilBuddySystemArrayCollection::getValues ( )

Gets all values of the collection.

Returns
array The values of all elements in the collection, in the order they appear in the collection.

Implements ilBuddySystemCollection.

Definition at line 181 of file class.ilBuddySystemArrayCollection.php.

182  {
183  return array_values($this->elements);
184  }

◆ isEmpty()

ilBuddySystemArrayCollection::isEmpty ( )

Returns
boolean true if the collection is empty, false otherwise.

Implements ilBuddySystemCollection.

Definition at line 165 of file class.ilBuddySystemArrayCollection.php.

166  {
167  return empty($this->elements);
168  }

◆ offsetExists()

ilBuddySystemArrayCollection::offsetExists (   $offset)

Definition at line 37 of file class.ilBuddySystemArrayCollection.php.

References containsKey().

38  {
39  return $this->containsKey($offset);
40  }
containsKey($key)
The index to check for. boolean true if the collection contains the element, false otherwise...
+ Here is the call graph for this function:

◆ offsetGet()

ilBuddySystemArrayCollection::offsetGet (   $offset)

Definition at line 45 of file class.ilBuddySystemArrayCollection.php.

46  {
47  return $this->get($offset);
48  }

◆ offsetSet()

ilBuddySystemArrayCollection::offsetSet (   $offset,
  $value 
)

Definition at line 53 of file class.ilBuddySystemArrayCollection.php.

References add().

54  {
55  if(!isset($offset))
56  {
57  $this->add($value);
58  return;
59  }
60 
61  $this->set($offset, $value);
62  }
add($element)
Adds an element at the end of the collection.
+ Here is the call graph for this function:

◆ offsetUnset()

ilBuddySystemArrayCollection::offsetUnset (   $offset)

Definition at line 67 of file class.ilBuddySystemArrayCollection.php.

68  {
69  $this->remove($offset);
70  }

◆ remove()

ilBuddySystemArrayCollection::remove (   $key)

Parameters
string | integer$keyThe index of the element to remove.
Exceptions
InvalidArgumentException

Implements ilBuddySystemCollection.

Definition at line 91 of file class.ilBuddySystemArrayCollection.php.

92  {
93  if(!isset($this->elements[$key]) && !array_key_exists($key, $this->elements))
94  {
95  throw new InvalidArgumentException(sprintf("Could not find an element for key: ", $key));
96  }
97  unset($this->elements[$key]);
98  }

◆ removeElement()

ilBuddySystemArrayCollection::removeElement (   $element)

Parameters
mixed$elementThe element to remove.
Exceptions
InvalidArgumentException

Implements ilBuddySystemCollection.

Definition at line 103 of file class.ilBuddySystemArrayCollection.php.

104  {
105  $key = array_search($element, $this->elements, true);
106  if(false === $key)
107  {
108  throw new InvalidArgumentException("Could not find an key for the passed element.");
109  }
110  unset($this->elements[$key]);
111  }

◆ set()

ilBuddySystemArrayCollection::set (   $key,
  $value 
)

Parameters
string  | integer$keyThe index of the element to set.
mixed$value

Implements ilBuddySystemCollection.

Definition at line 157 of file class.ilBuddySystemArrayCollection.php.

158  {
159  $this->elements[$key] = $value;
160  }

◆ slice()

ilBuddySystemArrayCollection::slice (   $offset,
  $length = null 
)

Extracts a slice of $length elements starting at position $offset from the Collection.If $length is null it returns all elements from $offset to the end of the Collection. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.

Parameters
int$offsetThe offset to start from.
int | null$lengthThe maximum number of elements to return, or null for no limit.
Returns
ilBuddySystemCollection

Implements ilBuddySystemCollection.

Definition at line 197 of file class.ilBuddySystemArrayCollection.php.

198  {
199  return new static(array_slice($this->elements, $offset, $length, true));
200  }

◆ toArray()

ilBuddySystemArrayCollection::toArray ( )
Returns
array

Implements ilBuddySystemCollection.

Definition at line 205 of file class.ilBuddySystemArrayCollection.php.

References $elements.

Field Documentation

◆ $elements

ilBuddySystemArrayCollection::$elements = array()
private

Definition at line 16 of file class.ilBuddySystemArrayCollection.php.

Referenced by __construct(), and toArray().


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