Generic map for PHP

Maintainers

Details

code.bgemi.net/Olive/map.git

Installs: 15

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/olivebbs/map

1.1.5 2025-09-24 15:36 UTC

This package is auto-updated.

Last update: 2025-09-24 21:32:41 UTC


README

Very simple typed map class.

Includes IntCharMap and CharMap as examples. It is best to extend Olivebbs\Map\GenericMap for your uses.

Example

use Olivebbs\Map\GenericMap;
use Olivebbs\Map\Enum\ValueType;
use Olivebbs\Map\Enum\KeyType;

final class MyStringMap extends GenericMap 
{
    public function __construct(array $values)
    {
        parent::__construct(KeyType::STRING, ValueType::STRING);
        $this->map->putAll($values);
    }
}

or

use Olivebbs\Map\GenericMap;
use Olivebbs\Map\Enum\ValueType;
use Olivebbs\Map\Enum\KeyType;

$myIntMap = new GenericMap(KeyType::INT, ValueType::INT); 

Then use it.

$myIntMap[0] = 500;
unset($myIntMap[0]) // null