ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 82 of file class.ilBuddySystemArrayCollection.php.

Referenced by offsetSet().

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

◆ clear()

ilBuddySystemArrayCollection::clear ( )

Clears the list.

Implements ilBuddySystemCollection.

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

References array.

131  {
132  $this->elements = array();
133  }
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 138 of file class.ilBuddySystemArrayCollection.php.

139  {
140  return in_array($element, $this->elements, true);
141  }

◆ 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 113 of file class.ilBuddySystemArrayCollection.php.

References $key.

Referenced by offsetExists().

114  {
115  return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
116  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ count()

ilBuddySystemArrayCollection::count ( )

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

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

◆ 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 186 of file class.ilBuddySystemArrayCollection.php.

187  {
188  return new static(array_filter($this->elements, $p));
189  }

◆ get()

ilBuddySystemArrayCollection::get (   $key)

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

Implements ilBuddySystemCollection.

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

References $key.

147  {
148  return isset($this->elements[$key]) ? $this->elements[$key] : null;
149  }
$key
Definition: croninfo.php:18

◆ 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 122 of file class.ilBuddySystemArrayCollection.php.

123  {
124  return array_search($element, $this->elements, true);
125  }

◆ 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 170 of file class.ilBuddySystemArrayCollection.php.

171  {
172  return array_keys($this->elements);
173  }

◆ 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 178 of file class.ilBuddySystemArrayCollection.php.

179  {
180  return array_values($this->elements);
181  }

◆ isEmpty()

ilBuddySystemArrayCollection::isEmpty ( )

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

Implements ilBuddySystemCollection.

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

163  {
164  return empty($this->elements);
165  }

◆ 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  $this->add($value);
57  return;
58  }
59 
60  $this->set($offset, $value);
61  }
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 66 of file class.ilBuddySystemArrayCollection.php.

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

◆ remove()

ilBuddySystemArrayCollection::remove (   $key)

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

Implements ilBuddySystemCollection.

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

References $key.

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

◆ removeElement()

ilBuddySystemArrayCollection::removeElement (   $element)

Parameters
mixed$elementThe element to remove.
Exceptions
InvalidArgumentException

Implements ilBuddySystemCollection.

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

References $key.

102  {
103  $key = array_search($element, $this->elements, true);
104  if (false === $key) {
105  throw new InvalidArgumentException("Could not find an key for the passed element.");
106  }
107  unset($this->elements[$key]);
108  }
$key
Definition: croninfo.php:18

◆ set()

ilBuddySystemArrayCollection::set (   $key,
  $value 
)

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

Implements ilBuddySystemCollection.

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

References $key.

155  {
156  $this->elements[$key] = $value;
157  }
$key
Definition: croninfo.php:18

◆ 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 194 of file class.ilBuddySystemArrayCollection.php.

195  {
196  return new static(array_slice($this->elements, $offset, $length, true));
197  }

◆ toArray()

ilBuddySystemArrayCollection::toArray ( )
Returns
array

Implements ilBuddySystemCollection.

Definition at line 202 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: