Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 3.61 KB

File metadata and controls

74 lines (57 loc) · 3.61 KB

API Surface

This reference reflects the current code in src/.

Main Public Entrypoints

  • JOOservices\UserAgent\Service\UserAgentService

    • generate(?GenerationSpec $spec = null, ?int $seed = null): string
    • generateWithMetadata(?GenerationSpec $spec = null, ?int $seed = null, ?string $profileName = null): GenerationResult
    • seed(int $seed): void — set RNG seed for deterministic generation
  • JOOservices\UserAgent\UserAgent (static facade)

    • generate(): string
    • generateWithMetadata(): GenerationResult
    • generateMany(int $count, bool $unique = true): array<string>
    • batch(int $count, array $options = []): BatchResult — options: unique, withMetadata, summary, spec
    • builder(): UserAgentBuilder — start a chain with no initial constraint
    • unique(): UserAgentBuilder
    • exclude(): UserAgentBuilder
    • resetUnique(): void
    • profile(): ProfileBuilder
    • supportedCombinations(): SupportedCombinations
    • seed(int $seed): void
    • scenario presets: scenarioPresetModernDesktop(), scenarioPresetMobileFirstApac(), scenarioPresetCrawlerSafeRotation(), scenarioPresetQaBrowserMatrix(): list<GenerationSpec>
    • bot: googlebot(bool $mobile = false), bingbot(bool $mobile = false), bot(BotType $type, bool $mobile = false)
    • chainable via __callStatic: browser/device/OS, asBot(BotType), botAsMobile(), versionMin(), versionMax(), versionExact(), locale(), arch(), recent(int $months)
  • JOOservices\UserAgent\Facade\UserAgentBuilder

    • browser: chrome(), firefox(), safari(), edge()
    • device: desktop(), mobile(), tablet()
    • os: windows(), macos(), linux(), android(), ios()
    • modes: unique(), exclude(), recent(int $months = 6)
    • optional spec: versionMin(int), versionMax(int), versionExact(int), locale(string), arch(string)
    • bot: asBot(BotType), botAsMobile(), googlebot(), bingbot(), bot(BotType)
    • output: generate(), generateWithMetadata(), generateMany(int $count), generateManyWithMetadata(int $count), toSpec(): GenerationSpec
  • JOOservices\UserAgent\Facade\ProfileBuilder

    • profile accessors: desktopChrome(), mobileSafari(), androidChrome() — return profile objects (e.g. DesktopChromeProfile with windows(), etc.)
    • quick methods (return string): randomMobile(?int $seed), randomDesktop(?int $seed), firefox(?int $seed), edge(?int $seed)
  • JOOservices\UserAgent\Service\Profiles\Profiles

    • profile objects and shortcut methods; use with UserAgentService instance.
  • JOOservices\UserAgent\Domain\Result\BatchResult

    • getResults(): array — list of UA strings or array{ua, metadata} when withMetadata was true
    • getSummary(): ?array['byBrowser' => [...], 'byOs' => [...]] when summary was true
  • JOOservices\UserAgent\Domain\Result\GenerationResult

    • getUaString(): string
    • getMetadata(): Meta
    • toArray(): array
  • JOOservices\UserAgent\Service\SupportedCombinations

    • getValidCombinations(): list<ValidCombination>
    • isValid(BrowserFamily, DeviceType, OperatingSystem): bool
  • JOOservices\UserAgent\Service\BotUserAgentService

    • generate(BotType $type, bool $mobile = false): string

CLI

  • script: bin/useragent (or ./vendor/bin/useragent)
  • runtime: JOOservices\UserAgent\Console\ConsoleApp
  • supporting classes: CliArgParser, CliSpecFactory, CliOutputFormatter

Next

Related