*/ public const LABELS = array( 'Books' => '本', 'Electronics' => '家電・カメラ', 'Computers' => 'パソコン・周辺機器', 'HomeAndKitchen' => 'ホーム・キッチン', 'Fashion' => 'ファッション', 'Beauty' => 'ビューティー', 'HealthPersonalCare' => 'ヘルスケア', 'SportsAndOutdoors' => 'スポーツ・アウトドア', 'Hobbies' => 'ホビー', 'Toys' => 'おもちゃ', 'Baby' => 'ベビー', 'GroceryAndGourmetFood' => '食品・飲料', 'PetSupplies' => 'ペット用品', ); /** * Default categories selected in the shortcode configurator. * * @var list */ public const DEFAULT_SELECTION = array( 'Electronics', 'HomeAndKitchen', 'Fashion', ); /** * Return all SearchIndex values. * * @return list */ public static function all(): array { return array_keys( self::LABELS ); } /** * Validate and deduplicate category tokens. * * @param list $values Raw values. * * @return list */ public static function normalize( array $values ): array { $normalized = array(); foreach ( $values as $value ) { if ( ! is_string( $value ) || ! array_key_exists( $value, self::LABELS ) ) { continue; } if ( ! in_array( $value, $normalized, true ) ) { $normalized[] = $value; } } return $normalized; } /** * Resolve a Japanese category label. * * @param string $searchIndex Amazon SearchIndex. */ public static function label( string $searchIndex ): string { return self::LABELS[ $searchIndex ] ?? $searchIndex; } }