for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace drupol\valuewrapper\Type;
use drupol\valuewrapper\AbstractValue;
use drupol\valuewrapper\ValueInterface;
use function gettype;
/**
* Class TypeValue.
*/
abstract class TypeValue extends AbstractValue implements TypeValueInterface
{
* {@inheritdoc}
public function __toArray(): array
return (array) $this->value();
}
public function equals(ValueInterface $item): bool
return $this->value() === $item->value();
public function hash(): string
return $this->doHash(var_export($this->value(), true));
public function serialize()
return serialize([
'value' => $this->value(),
]);
public function type(): string
return gettype($this->value());
public function unserialize($serialized)
$unserialize = unserialize($serialized);
$this->set($unserialize['value']);
protected function doHash(string $string): string
return parent::doHash($this->type() . $string);