PHP code example of fleshgrinder / equalable
1. Go to this page and download the library: Download fleshgrinder/equalable library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fleshgrinder / equalable example snippets
final class UserId implements Equalable {
private $uid;
// ...
public function equals($other): bool {
if ($other instanceof $this) {
$other = $other->uid;
}
return \is_int($other) && $this->uid === $other;
}
}
final class User implements Equalable {
private $uid;
private $name;
private $email;
// ...
public function equals($other): bool {
return $other instanceof $this && $this->uid->equals($other->uid);
}
}