Skip to content

Commit af3d10b

Browse files
authored
Merge pull request #38 from nicobleiler/alpha
Update docs
2 parents 5531e0a + 471a902 commit af3d10b

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Agents should run tests after meaningful changes, especially for behavior update
6666
- Keep service provider bindings/facade alias behavior intact.
6767
- The service provider wires `config/passphrase.php` values into `PassphraseGenerator::setDefaults()`.
6868
- `Passphrase::generate()` without arguments uses config defaults; explicit params override them.
69+
- `PassphraseGenerator::generate(targetEntropyBits: ...)` is a per-call entropy target and takes precedence over `numWords`.
70+
- `targetEntropyBits` is not part of `setDefaults()` and is not read from Laravel config (no `target_entropy_bits` key in `config/passphrase.php`).
6971
- If config keys change, update tests and docs consistently.
7072

7173
## Documentation Expectations

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,20 @@ echo $generator->generate(); // deterministic output
116116
| `wordSeparator` | `?string` | `'-'` | Character(s) between words. `null` uses instance/config default. |
117117
| `capitalize` | `?bool` | `false` | Capitalize the first letter of each word. `null` uses instance/config default. |
118118
| `includeNumber` | `?bool` | `false` | Append a random digit (0–9) to one random word. `null` uses instance/config default. |
119+
| `targetEntropyBits` | `?int` | `null` | Optional. Adjusts word count to meet or exceed this entropy target (in bits). Overrides `numWords` when set. |
119120

120-
All parameters are nullable — passing `null` (or omitting them) uses the defaults set via `setDefaults()` or `config/passphrase.php` in Laravel.
121+
All `generate()` parameters are nullable. For `numWords`, `wordSeparator`, `capitalize`, and `includeNumber`, passing `null` (or omitting them) uses defaults set via `setDefaults()` or `config/passphrase.php` in Laravel.
122+
123+
`targetEntropyBits` is evaluated per-call by `generate()` and is not loaded from `setDefaults()` (there is currently no `target_entropy_bits` config key).
124+
125+
When calling `generate()`, providing `targetEntropyBits` takes precedence over `numWords`.
126+
127+
```php
128+
$generator = new PassphraseGenerator();
129+
130+
// Entropy-based generation: numWords is calculated to reach at least 60 bits
131+
echo $generator->generate(targetEntropyBits: 60);
132+
```
121133

122134
These match [Bitwarden's passphrase generator options](https://bitwarden.com/passphrase-generator/) exactly.
123135

@@ -138,6 +150,8 @@ return [
138150
'capitalize' => false,
139151
'include_number' => false,
140152

153+
// No 'target_entropy_bits' key: targetEntropyBits is a per-call generate() override
154+
141155
// null = bundled EFF long word list (7,776 words)
142156
// Or provide your own word list as a PHP array of strings
143157
'word_list' => null,
@@ -148,7 +162,9 @@ return [
148162
];
149163
```
150164

151-
These config values are automatically used as defaults when calling `Passphrase::generate()` without explicit parameters. You can still override any option per-call.
165+
These config values are wired into `PassphraseGenerator::setDefaults()` and are automatically used as defaults when calling `Passphrase::generate()` without explicit parameters.
166+
167+
`targetEntropyBits` is not part of `setDefaults()` and therefore has no `target_entropy_bits` config key; pass it directly to `generate()` when you want entropy-targeted generation.
152168

153169
## Word Lists
154170

0 commit comments

Comments
 (0)