public function add(User $user) { if (null !== $this->find($user->getId())) { throw new \InvalidArgumentException('User already exists'); } $this->users[] = $user; }
public static function fromUser(User $user) { return new static(['id' => $user->getId(), 'email' => $user->getEmail(), 'name' => $user->getName()]); }