public function addConstraint($closure) { if (!$closure instanceof \Closure) { throw new \InvalidArgumentException('addConstraint() argument should be a \\Closure'); } $this->constraints[] = $closure; }