*/ public const LABELS = array( 'macos' => 'macOS', 'windows' => 'Windows', 'linux' => 'Linux', ); /** * Order a partial OS→path map by the canonical display order. * * Client classes declare only the operating systems they support, and they * write that array in whatever order suits the class. Callers must not * depend on that order. * * @param array $paths OS slug => path. May be partial. * @return array Ordered, with empty values dropped. */ public static function order( array $paths ): array { $ordered = array(); foreach ( self::LABELS as $slug => $label ) { if ( isset( $paths[ $slug ] ) && '' !== $paths[ $slug ] ) { $ordered[ $slug ] = $paths[ $slug ]; } } return $ordered; } /** * Human label for an OS slug, falling back to the slug itself. * * @param string $slug OS slug. * @return string */ public static function label( string $slug ): string { return self::LABELS[ $slug ] ?? $slug; } }