ILIAS  release_8 Revision v8.19
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=[])
 
 getIterator ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ()
 
 add ($element)
 
 remove ($key)
 
 removeElement ($element)
 
 containsKey ($key)
 isset is used for performance reasons (array_key_exists is much slower). More...
 
 getKey ($element)
 
 clear ()
 
 contains ($element)
 
 get ($key)
 
 set ($key, $value)
 
 isEmpty ()
 
 getKeys ()
 
 getValues ()
 
 filter (callable $callable)
 
 slice (int $offset, int $length=null)
 
 toArray ()
 
 equals ($other)
 

Private Attributes

array $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 26 of file class.ilBuddySystemArrayCollection.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $elements.

31  {
32  $this->elements = $elements;
33  }

Member Function Documentation

◆ add()

ilBuddySystemArrayCollection::add (   $element)

Implements ilBuddySystemCollection.

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

Referenced by offsetSet().

92  : void
93  {
94  $this->elements[] = $element;
95  }
+ Here is the caller graph for this function:

◆ clear()

ilBuddySystemArrayCollection::clear ( )

Implements ilBuddySystemCollection.

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

142  : void
143  {
144  $this->elements = [];
145  }

◆ contains()

ilBuddySystemArrayCollection::contains (   $element)

Implements ilBuddySystemCollection.

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

150  : bool
151  {
152  return in_array($element, $this->elements, true);
153  }

◆ containsKey()

ilBuddySystemArrayCollection::containsKey (   $key)

isset is used for performance reasons (array_key_exists is much slower).

array_key_exists is only used in case of a null value (see https://www.php.net/manual/en/function.array-key-exists.php Example #2 array_key_exists() vs isset()).

Implements ilBuddySystemCollection.

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by offsetExists(), and remove().

126  : bool
127  {
128  return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
129  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ count()

ilBuddySystemArrayCollection::count ( )

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

84  : int
85  {
86  return count($this->elements);
87  }

◆ equals()

ilBuddySystemArrayCollection::equals (   $other)
Parameters
mixed$other
Returns
bool

Implements ilBuddySystemCollection.

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

References toArray().

219  : bool
220  {
221  if (!($other instanceof self)) {
222  return false;
223  }
224 
225  $self = $this->toArray();
226  $other = $other->toArray();
227 
228  sort($self);
229  sort($other);
230 
231  return $self == $other;
232  }
+ Here is the call graph for this function:

◆ filter()

ilBuddySystemArrayCollection::filter ( callable  $callable)

Implements ilBuddySystemCollection.

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

Referenced by ilBuddySystemRelationStateFilterRule\getStates().

199  {
200  return new static(array_filter($this->elements, $callable));
201  }
Interface ilBuddySystemCollection.
+ Here is the caller graph for this function:

◆ get()

ilBuddySystemArrayCollection::get (   $key)

Implements ilBuddySystemCollection.

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

References ILIAS\LTI\ToolProvider\$key.

159  {
160  return $this->elements[$key] ?? null;
161  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ getIterator()

ilBuddySystemArrayCollection::getIterator ( )

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

39  {
40  return new ArrayIterator($this->elements);
41  }

◆ getKey()

ilBuddySystemArrayCollection::getKey (   $element)

Implements ilBuddySystemCollection.

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

135  {
136  return array_search($element, $this->elements, true);
137  }

◆ getKeys()

ilBuddySystemArrayCollection::getKeys ( )

Implements ilBuddySystemCollection.

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

182  : array
183  {
184  return array_keys($this->elements);
185  }

◆ getValues()

ilBuddySystemArrayCollection::getValues ( )

Implements ilBuddySystemCollection.

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

190  : array
191  {
192  return array_values($this->elements);
193  }

◆ isEmpty()

ilBuddySystemArrayCollection::isEmpty ( )

Implements ilBuddySystemCollection.

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

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

◆ offsetExists()

ilBuddySystemArrayCollection::offsetExists (   $offset)

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

References containsKey().

46  : bool
47  {
48  return $this->containsKey($offset);
49  }
containsKey($key)
isset is used for performance reasons (array_key_exists is much slower).
+ Here is the call graph for this function:

◆ offsetGet()

ilBuddySystemArrayCollection::offsetGet (   $offset)

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

55  {
56  return $this->get($offset);
57  }

◆ offsetSet()

ilBuddySystemArrayCollection::offsetSet (   $offset,
  $value 
)

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

References add().

62  : void
63  {
64  if (!isset($offset)) {
65  $this->add($value);
66 
67  return;
68  }
69 
70  $this->set($offset, $value);
71  }
+ Here is the call graph for this function:

◆ offsetUnset()

ilBuddySystemArrayCollection::offsetUnset (   $offset)

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

76  : void
77  {
78  $this->remove($offset);
79  }

◆ remove()

ilBuddySystemArrayCollection::remove (   $key)

Implements ilBuddySystemCollection.

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

References ILIAS\LTI\ToolProvider\$key, and containsKey().

100  : void
101  {
102  if (!$this->containsKey($key)) {
103  throw new InvalidArgumentException(sprintf('Could not find an element for key: %s', $key));
104  }
105  unset($this->elements[$key]);
106  }
string $key
Consumer key/client ID value.
Definition: System.php:193
containsKey($key)
isset is used for performance reasons (array_key_exists is much slower).
+ Here is the call graph for this function:

◆ removeElement()

ilBuddySystemArrayCollection::removeElement (   $element)

Implements ilBuddySystemCollection.

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

References ILIAS\LTI\ToolProvider\$key.

111  : void
112  {
113  $key = array_search($element, $this->elements, true);
114  if (false === $key) {
115  throw new InvalidArgumentException('Could not find an key for the passed element.');
116  }
117  unset($this->elements[$key]);
118  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ set()

ilBuddySystemArrayCollection::set (   $key,
  $value 
)

Implements ilBuddySystemCollection.

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

References ILIAS\LTI\ToolProvider\$key.

166  : void
167  {
168  $this->elements[$key] = $value;
169  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ slice()

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

Implements ilBuddySystemCollection.

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

207  {
208  return new static(array_slice($this->elements, $offset, $length, true));
209  }
Interface ilBuddySystemCollection.

◆ toArray()

ilBuddySystemArrayCollection::toArray ( )

Implements ilBuddySystemCollection.

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

References $elements.

Referenced by equals().

214  : array
215  {
216  return $this->elements;
217  }
+ Here is the caller graph for this function:

Field Documentation

◆ $elements

array ilBuddySystemArrayCollection::$elements
private

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

Referenced by __construct(), and toArray().


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