psx/record

Data HashMap implementation

Maintainers

👁 chriskapp

Package info

github.com/apioo/psx-record

Homepage

pkg:composer/psx/record

Statistics

Installs: 251 084

Dependents: 14

Suggesters: 0

Stars: 2

Open Issues: 0

v3.1.1 2025-12-14 08:42 UTC

Requires

  • php: >=8.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 ea0ae09b1cb935b0458ad79054f4218cb57e333d

datahashmaprecord


README

This package provides a simple HashMap implementation inspired by the Java HashMap API. The following example shows how to use the record class:

<?php

use PSX\Record\Record;

$record = new Record();
$record->put('foo', 'bar');
$record->putAll(['bar' => 'foo']);

$record->containsKey('foo'); // checks whether the key exists
$record->containsValue('bar'); // checks whether the value exists (strict type check)

$record->get('foo');
$record->getOrDefault('foo', false);
$record->foo; // property access
$record['foo']; // array access

$record->remove('bar');

$record->keySet(); // returns all keys as indexed array
$record->size(); // returns the size of the map
$record->values(); // returns all values as indexed array

\json_encode($record); // results in {"foo": "bar"}

$record = Record::from(['foo' => 'bar']); // create a record from an array