The base class for countable and JSON serializable collections.
- Class name: BaseCollection
- Namespace: PHPCollections\Collections
- This is an abstract class
- This class implements: Countable, JsonSerializable
protected \PHPCollections\DataHolder $dataHolder
The data container.
- Visibility: protected
void PHPCollections\Collections\BaseCollection::__construct(array $data)
Initializes the dataHolder property.
- Visibility: public
- $data array
void PHPCollections\Collections\BaseCollection::clear()
Reinitializes the dataHolder property.
- Visibility: public
boolean PHPCollections\Collections\ArrayList::contains(mixed $needle)
Checks if the collection contains a given value.
- Visibility: public
- $needle mixed
integer PHPCollections\Collections\BaseCollection::count()
Returns the length of the collection.
- Visibility: public
Basecollection PHPCollections\Collections\BaseCollection::diff(Basecollection $collection)
Gets the difference between two collections.
- Visibility: public abstract
- $collection \PHPCollections\Collections\BaseCollection
boolean PHPCollections\Collections\BaseCollection::exists(mixed $offset)
Checks if the given index exists in the collection.
- Visibility: public
boolean PHPCollections\Collections\BaseCollection::equals(BaseCollection $collection)
Determines if two collections are equal.
- Visibility: public abstract
- $collection \PHPCollections\Collections\BaseCollection
void PHPCollections\Collections\BaseCollection::fill()
Fills the collection with a set of data.
- Visibility: public
mixed PHPCollections\Collections\BaseCollection::first()
Gets the first element in the collection.
- Visibility: public
\OutOfRangeException
boolean PHPCollections\Collections\BaseCollection::isEmpty()
Checks if the collection is empty.
- Visibility: public
\OutOfRangeException
array PHPCollections\Collections\BaseCollection::jsonSerialize()
Defines the behavior of the collection when json_encode is called.
- Visibility: public
mixed PHPCollections\Collections\BaseCollection::last()
Gets the last element in the collection.
- Visibility: public
array PHPCollections\Collections\BaseCollection::toArray()
Returns a plain array with your dictionary data.
- Visibility: public
?BaseCollection PHPCollections\Collections\BaseCollection::slice(int $offset, ?int $length = null)
Returns a portion of the collection.
- Visibility: public abstract
- $offset int
- $length int
float PHPCollections\Collections\BaseCollection::sum(callable $callback)
Returns the sum of a set of values.
- Visibility: public
- $callback callable
\OutOfRangeException