is_public || $this->isOwner($user, $webhookEndpoint); } public function create(?User $user): bool { return $user !== null; } public function update(?User $user, WebhookEndpoint $webhookEndpoint): bool { return ! $webhookEndpoint->is_public && $this->isOwner($user, $webhookEndpoint); } public function delete(?User $user, WebhookEndpoint $webhookEndpoint): bool { return ($webhookEndpoint->is_public && $webhookEndpoint->user_id === null) || $this->isOwner($user, $webhookEndpoint); } private function isOwner(?User $user, WebhookEndpoint $webhookEndpoint): bool { return $user !== null && (string) $webhookEndpoint->user_id === (string) $user->getKey(); } }