'Presseecho', self::Businessportal24 => 'Businessportal24', self::Both => 'Beide Portale', }; } public function abbreviation(): string { return match ($this) { self::Presseecho => 'PE', self::Businessportal24 => 'B24', self::Both => 'PE+B24', }; } public static function stripTrailingAbbreviation(string $value): string { $abbreviations = implode('|', array_map( fn (self $portal): string => preg_quote($portal->abbreviation(), '/'), self::cases(), )); return trim((string) preg_replace('/\s*\(('.$abbreviations.')\)\s*$/u', '', $value)); } }