Equatable
Tells whether an object is equal to other value.
Overview
/** @implements Equatable<self> */
class Phone implements Equatable
{
public function __construct(private string $value) {}
public function equals(self $other): bool
{
return $this->value === $other->value;
}
}
assert(true === (new Phone('(321) 456-1234'))->equals(new Phone('(321) 456-1234')));
assert(false === (new Phone('(321) 456-1234'))->equals(new Phone('(454) 456-1234')));Design decisions
Last updated