user = $user; } public function can(string $action, mixed $subject) : bool { $is_destructive = in_array($action, self::DESTRUCTIVE_ACTIONS); if (is_a($subject, 'PonePaste\\Models\\Paste')) { if (((int) $subject->visible === Paste::VISIBILITY_PRIVATE) || $is_destructive) { return $this->user !== null && $subject->user_id === $this->user->id; } return true; } if (is_a($subject, 'PonePaste\\Models\\User')) { return !$is_destructive || ($this->user !== null && $subject->id === $this->user->id); } return false; } }