Skip to content

chore(emulation): add platform enum for cross-platform header generation#21

Merged
danielhe4rt merged 1 commit into
0.xfrom
chore/platform-enum
May 15, 2026
Merged

chore(emulation): add platform enum for cross-platform header generation#21
danielhe4rt merged 1 commit into
0.xfrom
chore/platform-enum

Conversation

@danielhe4rt
Copy link
Copy Markdown
Contributor

Summary

  • Add Platform enum (MacOS, Windows, Linux, Android, iOS) with:
    • secChUaPlatform()"macOS", "Windows", etc.
    • isMobile()true for Android/iOS
    • userAgentPlatform() → platform-specific UA string
    • random() → random platform selection
  • Add ClientBuilder::platform(Platform) that rewrites profile headers at build time:
    • User-Agent → platform-specific (Macintosh → Windows NT → X11 Linux → Android → iPhone)
    • sec-ch-ua-platform → matching platform string
    • sec-ch-ua-mobile?1 for mobile, ?0 for desktop
  • Add Browser::random() for random browser selection

Usage

$client = Client::builder()
    ->emulation(Browser::Chrome145)
    ->platform(Platform::Windows)  // Windows UA + headers
    ->build();

// Random browser + platform
$client = Client::builder()
    ->emulation(Browser::random())
    ->platform(Platform::random())
    ->build();

Test plan

  • Platform enum: 5 cases, correct backed values, mobile detection, UA strings
  • ClientBuilder: Windows platform changes UA to "Windows NT 10.0", Android sets mobile=?1
  • Platform doesn't affect profiles without sec-ch-ua headers
  • Browser::random() returns valid Browser case
  • PHPStan level max: 0 errors

add Platform enum (MacOS, Windows, Linux, Android, iOS) that controls
User-Agent, sec-ch-ua-platform, and sec-ch-ua-mobile headers.
ClientBuilder::platform() applies overrides at build time by rewriting
the profile's default headers.

add Browser::random() and Platform::random() for random profile
selection.
@danielhe4rt danielhe4rt force-pushed the chore/platform-enum branch from 88c78a6 to 0b06083 Compare May 15, 2026 04:07
@danielhe4rt danielhe4rt merged commit dc05676 into 0.x May 15, 2026
0 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant