Skip to content
docsv0.24.0

GenerationContext

Everything a generator needs: the target plugin, the artifact name, CLI options, and repo root.

GenerationContext::__construct()

public function __construct(string $plugin, string $name, array $options, string $root):

Parameters

Parameters of __construct()
NameTypeDescription
$pluginstring
$namestring
$optionsarray<string, mixed>
$rootstring

GenerationContext::option()

public function option(string $key): ?string

Reads a CLI `--option` value; `null` when absent or not a string.

Parameters

Parameters of option()
NameTypeDescription
$keystring

GenerationContext::flag()

public function flag(string $key): bool

Reads a boolean-ish CLI `--flag` (e.g. `--force`, used to re-run a {@see \Milpa\DevTools\Make\MarkerInserter} insertion that already landed once): a native `bool` is returned as-is, a string is truthy unless it is `''`, `'0'`, or `'false'` (case-insensitive) — mirrors {@see \Milpa\DevTools\Make\Generators\ServiceGenerator}'s pre-existing `--interface` parsing exactly. Absent or any other type reads as `false`.

Parameters

Parameters of flag()
NameTypeDescription
$keystring