getUser()?->can($abilities, $arguments) ?? false; } public function check(): bool { return $this->guard->check(); } public function guest(): bool { return ! $this->check(); } public function getUser(): ?User { $user = $this->guard->user(); if ($user && ! ($user instanceof User)) { throw new \InvalidArgumentException('Auth service needs a backend guard'); } return $user ? clone $user : null; } public function getUserAsMandatory(): User { $user = $this->getUser(); if ($user === null) { throw new AuthServiceException('Authenticated user is required from here'); } return clone $user; } public function getMandatoryUserId(): string { return (string) $this->getUserAsMandatory()->id; } }