PHP Basics

Interface Traits

This package contains some traits implementing common interfaces, which can easily be used in any class that internally uses an array for holding its properties or data. They also share the same internal logic to allow combining multiple traits within the same class.

ArrayAccessTrait

A generic implementation of the ArrayAccess interface.

The \ArrayAccess interface allows objects to be accessed like arrays.

Usage:

class Foo implements ArrayAccess
{
    use \OCC\Basics\Interfaces\ArrayAccessTrait;
}

CountableTrait

A generic implementation of the Countable interface.

The \Countable interface allows objects to be used with the count() function.

Usage:

class Foo implements Countable
{
    use \OCC\Basics\Interfaces\CountableTrait;
}

IteratorAggregateTrait

A generic implementation of the IteratorAggregate interface.

The \IteratorAggregate interface creates an external \ArrayIterator for traversing the object's internal data array.

Usage:

class Foo implements IteratorAggregate
{
    use \OCC\Basics\Interfaces\IteratorAggregateTrait;
}

IteratorTrait

A generic implementation of the Iterator interface.

The \Iterator interface creates an internal iterator for traversing the object's data array.

Usage:

class Foo implements Iterator
{
    use \OCC\Basics\Interfaces\IteratorTrait;
}

Search results