Skip to content

Commit d190104

Browse files
author
lucia
committed
align with style docs
1 parent 592117b commit d190104

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

docs/filtering-and-sorting.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ there's no point fetching rows you won't use. These methods are for the
1919
result you already have: one loaded collection sliced different ways for
2020
different parts of the page, with no extra queries.
2121

22-
The `where()` method keeps the rows where a field matches a value. Chain it
23-
to match on more than one field:
22+
`where()` keeps the rows where a field matches a value. Chain it to match on
23+
more than one field:
2424

2525
```php
2626
use Itools\SmartArray\SmartArrayHtml;
@@ -115,10 +115,10 @@ original keys; chain `values()` when you want them renumbered.
115115

116116
## Sorting: sortBy() and sort()
117117

118-
The `sortBy()` method orders rows by a field. It returns a new sorted
119-
collection and never modifies the original (PHP's own `sort()` modifies
120-
arrays in place; SmartArray methods don't), so your result stays in query
121-
order and can be sorted different ways for different spots on the page:
118+
`sortBy()` orders rows by a field. It returns a new sorted collection and
119+
never modifies the original (PHP's own `sort()` modifies arrays in place;
120+
SmartArray methods don't), so your result stays in query order and can be
121+
sorted different ways for different spots on the page:
122122

123123
```php
124124
$funds = SmartArrayHtml::new([
@@ -144,10 +144,10 @@ echo $tags->sort()->implode(', '); // Apache, MySQL, PHP
144144

145145
## Duplicates and Membership: unique() and contains()
146146

147-
The `unique()` method drops repeated values from a flat list, keeping the first
148-
of each, and `contains()` to ask whether a value is in the list at all.
149-
Both treat `1` and `'1'` as the same value (`contains()` follows the same
150-
matching rules as `where()`):
147+
`unique()` drops repeated values from a flat list, keeping the first of each,
148+
and `contains()` to ask whether a value is in the list at all. Both treat `1`
149+
and `'1'` as the same value (`contains()` follows the same matching rules as
150+
`where()`):
151151

152152
```php
153153
$tags = SmartArrayHtml::new(['PHP', 'MySQL', 'PHP', 'Apache']);

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ if ($users->isEmpty()) {
9797
}
9898

9999
foreach ($users as $user) {
100-
echo "<li>$user->name - {$user->phone->or('no phone on file')}</li>\n";
100+
echo "<li>$user->name - {$user->phone->or('(no phone)')}</li>\n";
101101
}
102102
// <li>Jean O&​apos;Brien - 604-555-1234</li>
103-
// <li>Sam Smith - no phone on file</li>
103+
// <li>Sam Smith - (no phone)</li>
104104
```
105105

106106
No `else` is needed: a `foreach` over an empty collection runs zero times.

docs/transforming-and-grouping.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Contents:
1313

1414
## Pulling One Column: column()
1515

16-
The `column()` method returns a flat list of one field from every row, like
17-
PHP's `array_column()` (including the keyed form below):
16+
`column()` returns a flat list of one field from every row, like PHP's
17+
`array_column()` (including the keyed form below):
1818

1919
```php
2020
use Itools\SmartArray\SmartArrayHtml;
@@ -39,8 +39,8 @@ echo $nameById->{7}; // Alice Munro
3939

4040
## Keying Rows for Lookups: indexBy()
4141

42-
The `indexBy()` method keys whole rows by a field, turning "loop until you find
43-
it" into a direct lookup:
42+
`indexBy()` keys whole rows by a field, turning "loop until you find it" into
43+
a direct lookup:
4444

4545
```php
4646
$authorsById = $authors->indexBy('author_id');
@@ -100,8 +100,8 @@ keys are trusted values you defined yourself.
100100

101101
## Reshaping Rows: map()
102102

103-
The `map()` method rebuilds each element with a callback. Like `filter()`, the
104-
callback receives plain PHP values, so you write ordinary PHP inside it:
103+
`map()` rebuilds each element with a callback. Like `filter()`, the callback
104+
receives plain PHP values, so you write ordinary PHP inside it:
105105

106106
```php
107107
$labels = $authors->map(fn($a) => "$a[name] ($a[city])");

docs/without-smartstrings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ above: every selected column exists on every row, so a truly missing key
5050
means a typo, and typos on result rows warn on their own. Missing keys as a
5151
normal case only come up in arrays you assemble yourself.
5252

53-
The `??` operator doesn't fire on stored `""`, because an empty string is a
54-
stored value. On the HTML side, use `or()` instead; it covers `""` and keeps
55-
fallbacks encoded (see [Displaying Fields](displaying-fields.md)).
53+
`??` doesn't fire on stored `""`, because an empty string is a stored value.
54+
On the HTML side, use `or()` instead; it covers `""` and keeps fallbacks
55+
encoded (see [Displaying Fields](displaying-fields.md)).
5656

5757
In hand-built arrays, stick with `??` rather than a truthiness check: a
5858
key that doesn't exist at all comes back as a placeholder object so

tests/Integration/DocsExamplesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ public function testGettingStartedIsEmptyGuardAndOrFallback(): void
156156
}
157157

158158
foreach ($users as $user) {
159-
echo "<li>$user->name - {$user->phone->or('no phone on file')}</li>\n";
159+
echo "<li>$user->name - {$user->phone->or('(no phone)')}</li>\n";
160160
}
161161
});
162162

163163
$this->assertSame(
164-
"<li>Jean O&apos;Brien - 604-555-1234</li>\n<li>Sam Smith - no phone on file</li>\n",
164+
"<li>Jean O&apos;Brien - 604-555-1234</li>\n<li>Sam Smith - (no phone)</li>\n",
165165
$output
166166
);
167167
}

0 commit comments

Comments
 (0)