/** * @param User $user * @throws \InvalidArgumentException If $user is not valid */ public function __construct(User $user) { if ($user->isValid() === false) { throw new \InvalidArgumentException("User::isValid() returned false"); } $this->setModel($user); }