3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Contains { /** * @var string */ private $comparedValue; /** * Creates the expression. * * @param string $comparedValue The compared value. */ public function __construct($comparedValue) { $this->comparedValue = $comparedValue; } /** * Returns the accepted suffix. * * @return string The accepted suffix. */ public function getComparedValue() { return $this->comparedValue; } public function equivalentTo(Expression $other) { // Since this class is final, we can check with instanceof return $other instanceof $this && $this->comparedValue == $other->comparedValue; } } $a = new Contains('foobar'); $b = new Contains(0); var_dump($a->equivalentTo($b));

preferences:
44.67 ms | 402 KiB | 5 Q