ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 @inheritDoc More...
 
 offsetExists ($offset)
 @inheritDoc More...
 
 offsetGet ($offset)
 @inheritDoc More...
 
 offsetSet ($offset, $value)
 @inheritDoc More...
 
 offsetUnset ($offset)
 @inheritDoc More...
 
 count ()
 @inheritDoc More...
 
 add ($element)
 @inheritDoc More...
 
 remove ($key)
 @inheritDoc More...
 
 removeElement ($element)
 @inheritDoc More...
 
 containsKey ($key)
 @inheritDoc More...
 
 getKey ($element)
 @inheritDoc More...
 
 clear ()
 @inheritDoc More...
 
 contains ($element)
 @inheritDoc More...
 
 get ($key)
 @inheritDoc More...
 
 set ($key, $value)
 @inheritDoc More...
 
 isEmpty ()
 @inheritDoc More...
 
 getKeys ()
 @inheritDoc More...
 
 getValues ()
 @inheritDoc More...
 
 filter (callable $callable)
 @inheritDoc More...
 
 slice ($offset, $length=null)
 @inheritDoc More...
 
 toArray ()
 @inheritDoc More...
 
 add ($element)
 Adds an element at the end of the collection. More...
 
 remove ($key)
 
 removeElement ($element)
 
 containsKey ($key)
 
 getKey ($element)
 
 clear ()
 Clears the list. More...
 
 contains ($element)
 
 get ($key)
 
 set ($key, $value)
 
 isEmpty ()
 
 getKeys ()
 Gets all indices of the collection. More...
 
 getValues ()
 Gets all values of the collection. More...
 
 filter (callable $callable)
 Returns all the elements of this collection that satisfy the predicate $callable. More...
 
 slice ($offset, $length=null)
 Extracts a slice of $length elements starting at position $offset from the Collection. More...
 
 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.

Member Function Documentation

◆ add()

ilBuddySystemArrayCollection::add (   $element)

@inheritDoc

Implements ilBuddySystemCollection.

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

79 : void
80 {
81 $this->elements[] = $element;
82 }

Referenced by offsetSet().

+ Here is the caller graph for this function:

◆ clear()

ilBuddySystemArrayCollection::clear ( )

@inheritDoc

Implements ilBuddySystemCollection.

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

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

◆ contains()

ilBuddySystemArrayCollection::contains (   $element)

@inheritDoc

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)

@inheritDoc

Implements ilBuddySystemCollection.

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

110 : bool
111 {
112 return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
113 }

Referenced by offsetExists().

+ Here is the caller graph for this function:

◆ count()

ilBuddySystemArrayCollection::count ( )

@inheritDoc

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

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

References count().

Referenced by count().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filter()

ilBuddySystemArrayCollection::filter ( callable  $callable)

@inheritDoc

Implements ilBuddySystemCollection.

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

183 {
184 return new static(array_filter($this->elements, $callable));
185 }

Referenced by ilBuddySystemRelationStateFilterRule\getStates().

+ Here is the caller graph for this function:

◆ get()

ilBuddySystemArrayCollection::get (   $key)

@inheritDoc

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 ( )

@inheritDoc

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

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

◆ getKey()

ilBuddySystemArrayCollection::getKey (   $element)

@inheritDoc

Implements ilBuddySystemCollection.

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

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

◆ getKeys()

ilBuddySystemArrayCollection::getKeys ( )

@inheritDoc

Implements ilBuddySystemCollection.

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

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

◆ getValues()

ilBuddySystemArrayCollection::getValues ( )

@inheritDoc

Implements ilBuddySystemCollection.

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

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

◆ isEmpty()

ilBuddySystemArrayCollection::isEmpty ( )

@inheritDoc

Implements ilBuddySystemCollection.

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

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

◆ offsetExists()

ilBuddySystemArrayCollection::offsetExists (   $offset)

@inheritDoc

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

35 {
36 return $this->containsKey($offset);
37 }

References containsKey().

+ Here is the call graph for this function:

◆ offsetGet()

ilBuddySystemArrayCollection::offsetGet (   $offset)

@inheritDoc

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

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

◆ offsetSet()

ilBuddySystemArrayCollection::offsetSet (   $offset,
  $value 
)

@inheritDoc

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

51 {
52 if (!isset($offset)) {
53 $this->add($value);
54 return;
55 }
56
57 $this->set($offset, $value);
58 }

References add().

+ Here is the call graph for this function:

◆ offsetUnset()

ilBuddySystemArrayCollection::offsetUnset (   $offset)

@inheritDoc

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

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

◆ remove()

ilBuddySystemArrayCollection::remove (   $key)

@inheritDoc

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)

@inheritDoc

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 
)

@inheritDoc

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 
)

@inheritDoc

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 ( )

@inheritDoc

Implements ilBuddySystemCollection.

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

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

References $elements.

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: