withClosureValidation(function($oldInstance, $newInstance) use ($properties) { foreach ((array)$properties as $property) { $method = "get" . ucfirst($property); if (!method_exists($oldInstance, $method)) { throw new AllowOnlyNewValuesConstraintException("The property '$property' does not exists in the old instance."); } if (!method_exists($newInstance, $method)) { throw new AllowOnlyNewValuesConstraintException("The property '$property' does not exists in the new instance."); } if ($oldInstance->$method() == $newInstance->$method()) { throw new AllowOnlyNewValuesConstraintException("You are not updating the property '$property' "); } } return true; }); return $this; } public function withClosureValidation(Closure $closure): self { $this->closureValidation[] = $closure; return $this; } /** * @throws UpdateConstraintException */ public function check(mixed $oldInstance, mixed $newInstance): void { foreach ($this->closureValidation as $closure) { if ($closure($oldInstance, $newInstance) !== true) { throw new UpdateConstraintException("The Update Constraint validation failed"); } } } }__halt_compiler();----SIGNATURE:----X0/41OIQAJoGaPPD32dv4YhsXokeDk3Te/FvGMhnV7X2++k65sv56bxDh9+klVJc5bpI+CQXovpEnk5MUCxdE+3kWOYVRpbc4iveElf2rzM53OJzAyxZ+txw3b2Up2uUY96vMulSj3EnX7UHJDZZKJguhgqaP0oz/s9v7iUS3tp3qRILkUqac7/jkhjTeW53eGTw6xCgnIVd2awzXqviIptHOO+naZy0+P7swNgj8RLNqRKCIg75mNSTAPsQMTawAnkde0S9ZjNCWxQtOjHGiUUzLwrWn8D+fvlmoQG8/tDDufmEaibt5bI6g4B+TtBsUTAeZBCR59wAv5I79OJCARKwGLhRyXuvCI064Z+PGAnKpDBr78Gb2X29mc6oS0oUGxuZUf6YnrZ1x4cj2Ito+Y4SY8NFhBPL8Ml2UeOG+iwaDe3QhEm6rtuxBsH6tO3TmApgX+c3A5BVpmjO5a1K4vLCiBd2/CjkQ+da+gwBdy037Wtq0Eb89AqChKLo4kMOxZi/Jp9RsYmh9Km9M/5wDtuovnow6IhfT7oHKLxwdTGcupJct05ywI0TArMShTv9/wIEl8FuILisTxECepFD+I+sUm/E+N6gyZVhEeRBbI1vpusVcY9gxn7tHM80CDQcdXNke7Pmdcw4nbAH+VyAsOXqLSi2bGVxXjGDKD0AGgI=----ATTACHMENT:----MzUxMTI2MTE2NjM4MzI3MCAzMTg2NDQ4NTE2OTEyNjM3IDcwNDcwNDA3MTUzMjY1ODY=