Functions
A set of simple functions that extend the standard PHP functions API
use function Jungi\Common\equals;
/** @implements Equatable<self> */
class ContactInformation implements Equatable
{
public function __construct(
private Phone $phone,
private ?Phone $mobile = null
) {}
public function equals(self $other): bool
{
return $this->phone->equals($other->phone)
&& equals($this->mobile, $other->mobile);
}
}
$a = new ContactInformation(new Phone('(321) 456-1234'), new Phone('(886) 456-6543'));
$b = new ContactInformation(new Phone('(321) 456-1234'), new Phone('(886) 456-6543'));
assert(true === equals($a, $b);
$a = new ContactInformation(new Phone('(321) 456-1234'));
$b = new ContactInformation(new Phone('(321) 456-1234'));
assert(true === equals($a, $b);
$a = new ContactInformation(new Phone('(321) 456-1234'));
$b = new ContactInformation(new Phone('(321) 456-1234'), new Phone('(886) 456-6543'));
assert(false === equals($a, $b);
assert(false === equals($b, $a);Last updated