ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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=[])
 ilBuddySystemArrayCollection constructor. More...
 
 getIterator ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ()
 
 add ($element)
 
 remove ($key)
 
 removeElement ($element)
 
 containsKey ($key)
 
 getKey ($element)
 
 clear ()
 
 contains ($element)
 
 get ($key)
 
 set ($key, $value)
 
 isEmpty ()
 
 getKeys ()
 
 getValues ()
 
 filter (callable $callable)
 
 slice ($offset, $length=null)
 
 toArray ()
 

Private Attributes

 $elements = []
 

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

Constructor & Destructor Documentation

◆ __construct()

ilBuddySystemArrayCollection::__construct ( array  $elements = [])

ilBuddySystemArrayCollection constructor.

Parameters
array$elements

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

References $elements.

19  {
20  $this->elements = $elements;
21  }

Member Function Documentation

◆ add()

ilBuddySystemArrayCollection::add (   $element)

Implements ilBuddySystemCollection.

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

Referenced by offsetSet().

79  : void
80  {
81  $this->elements[] = $element;
82  }
+ Here is the caller graph for this function:

◆ clear()

ilBuddySystemArrayCollection::clear ( )

Implements ilBuddySystemCollection.

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

126  : void
127  {
128  $this->elements = [];
129  }

◆ contains()

ilBuddySystemArrayCollection::contains (   $element)

Implements ilBuddySystemCollection.

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

134  : bool
135  {
136  return in_array($element, $this->elements, true);
137  }

◆ containsKey()

ilBuddySystemArrayCollection::containsKey (   $key)

Implements ilBuddySystemCollection.

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

Referenced by offsetExists().

110  : bool
111  {
112  return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
113  }
+ Here is the caller graph for this function:

◆ count()

ilBuddySystemArrayCollection::count ( )

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

72  {
73  return count($this->elements);
74  }

◆ filter()

ilBuddySystemArrayCollection::filter ( callable  $callable)

Implements ilBuddySystemCollection.

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

Referenced by ilBuddySystemRelationStateFilterRule\getStates().

183  {
184  return new static(array_filter($this->elements, $callable));
185  }
+ Here is the caller graph for this function:

◆ get()

ilBuddySystemArrayCollection::get (   $key)

Implements ilBuddySystemCollection.

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

143  {
144  return isset($this->elements[$key]) ? $this->elements[$key] : null;
145  }

◆ getIterator()

ilBuddySystemArrayCollection::getIterator ( )

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

27  {
28  return new ArrayIterator($this->elements);
29  }

◆ getKey()

ilBuddySystemArrayCollection::getKey (   $element)

Implements ilBuddySystemCollection.

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

119  {
120  return array_search($element, $this->elements, true);
121  }

◆ getKeys()

ilBuddySystemArrayCollection::getKeys ( )

Implements ilBuddySystemCollection.

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

166  : array
167  {
168  return array_keys($this->elements);
169  }

◆ getValues()

ilBuddySystemArrayCollection::getValues ( )

Implements ilBuddySystemCollection.

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

174  : array
175  {
176  return array_values($this->elements);
177  }

◆ isEmpty()

ilBuddySystemArrayCollection::isEmpty ( )

Implements ilBuddySystemCollection.

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

158  : bool
159  {
160  return empty($this->elements);
161  }

◆ offsetExists()

ilBuddySystemArrayCollection::offsetExists (   $offset)

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

References containsKey().

35  {
36  return $this->containsKey($offset);
37  }
+ Here is the call graph for this function:

◆ offsetGet()

ilBuddySystemArrayCollection::offsetGet (   $offset)

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

43  {
44  return $this->get($offset);
45  }

◆ offsetSet()

ilBuddySystemArrayCollection::offsetSet (   $offset,
  $value 
)

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

References add().

51  {
52  if (!isset($offset)) {
53  $this->add($value);
54  return;
55  }
56 
57  $this->set($offset, $value);
58  }
+ Here is the call graph for this function:

◆ offsetUnset()

ilBuddySystemArrayCollection::offsetUnset (   $offset)

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

64  {
65  $this->remove($offset);
66  }

◆ remove()

ilBuddySystemArrayCollection::remove (   $key)

Implements ilBuddySystemCollection.

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

87  : void
88  {
89  if (!isset($this->elements[$key]) && !array_key_exists($key, $this->elements)) {
90  throw new InvalidArgumentException(sprintf("Could not find an element for key: %s", $key));
91  }
92  unset($this->elements[$key]);
93  }

◆ removeElement()

ilBuddySystemArrayCollection::removeElement (   $element)

Implements ilBuddySystemCollection.

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

98  : void
99  {
100  $key = array_search($element, $this->elements, true);
101  if (false === $key) {
102  throw new InvalidArgumentException("Could not find an key for the passed element.");
103  }
104  unset($this->elements[$key]);
105  }

◆ set()

ilBuddySystemArrayCollection::set (   $key,
  $value 
)

Implements ilBuddySystemCollection.

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

150  : void
151  {
152  $this->elements[$key] = $value;
153  }

◆ slice()

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

Implements ilBuddySystemCollection.

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

191  {
192  return new static(array_slice($this->elements, $offset, $length, true));
193  }

◆ toArray()

ilBuddySystemArrayCollection::toArray ( )

Implements ilBuddySystemCollection.

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

References $elements.

198  : array
199  {
200  return $this->elements;
201  }

Field Documentation

◆ $elements

ilBuddySystemArrayCollection::$elements = []
private

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

Referenced by __construct(), and toArray().


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