parent
096d4bc3ed
commit
044e50007c
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace jrosset\ArrayClasses;
|
||||
|
||||
/**
|
||||
* An immutable array with insensitive case cell name
|
||||
*/
|
||||
class ImmutableInsensitiveCaseArrayClass implements IImmutableArrayClass {
|
||||
use TImmutableInternalArray {
|
||||
has as private has__TImmutableInternalArray;
|
||||
get as private get__TImmutableInternalArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function has ($cellName): bool {
|
||||
return $this->has__TImmutableInternalArray(mb_strtolower($cellName));
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get ($cellName, ?bool $throwsForNonExistentElement = null) {
|
||||
return $this->get__TImmutableInternalArray(mb_strtolower($cellName), $throwsForNonExistentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toMutable (): IArrayClass {
|
||||
return new InsensitiveCaseArrayClass($this->array, $this->throwsForNonExistentElement());
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace jrosset\ArrayClasses;
|
||||
|
||||
/**
|
||||
* An array with insensitive case cell name
|
||||
*/
|
||||
class InsensitiveCaseArrayClass extends ImmutableInsensitiveCaseArrayClass implements IArrayClass {
|
||||
use TInternalArray {
|
||||
set as private set__TInternalArray;
|
||||
del as private del__TInternalArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function set ($cellName, $cellValue): self {
|
||||
return $this->set__TInternalArray(mb_strtolower($cellName), $cellValue);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function del ($cellName, ?bool $throwsForNonExistentElement = null): self {
|
||||
return $this->del__TInternalArray(mb_strtolower($cellName), $throwsForNonExistentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toImmutable (): IImmutableArrayClass {
|
||||
return new ImmutableInsensitiveCaseArrayClass($this->array, $this->throwsForNonExistentElement());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue