categoryId !== Category::OTHER_MISC && $this->confidence > 0; } /** * Check if this result should take precedence over another. */ public function shouldOverride(CategorizationResult $other): bool { // Higher confidence always wins if ($this->confidence > $other->confidence) { return true; } // If same confidence, prefer non-misc categories if ($this->confidence === $other->confidence) { return $this->categoryId !== Category::OTHER_MISC && $other->categoryId === Category::OTHER_MISC; } return false; } /** * Create a failed/empty result. */ public static function noMatch(): self { return new self(Category::OTHER_MISC, 0.0, 'no_match'); } /** * Create a result with debug info merged. */ public function withDebug(array $additionalDebug): self { return new self( $this->categoryId, $this->confidence, $this->matchedBy, array_merge($this->debug, $additionalDebug) ); } }