You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Web/Documentation/content/main/1-framework/15-primitive-utilities.md
+10-12Lines changed: 10 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,21 +7,19 @@ Tempest comes with a handful of classes that improve working with primitive type
7
7
8
8
## Strings
9
9
10
-
The `StringHelper` class wraps a normal string, and provides a fluent API to manipulate that string. Note that all these methods are immutable, so every call creates a new instance of `StringHelper` without modifying the original one.
10
+
The `ImmutableString` and `MutableString` classes wraps a normal string, and provide a fluent API to manipulate that string.
11
11
12
12
```php
13
-
use Tempest\Support\StringHelper;
13
+
use Tempest\Support\Str\ImmutableString;
14
14
15
-
$slug = (new StringHelper('https://tempestphp.com/docs/framework/14-primitive-helpers'))
15
+
$slug = (new ImmutableString('https://tempestphp.com/docs/framework/14-primitive-helpers'))
16
16
->trim('/')
17
17
->afterLast('/')
18
18
->replaceRegex('/\d+-/', '')
19
19
->toString();
20
-
21
-
// primitive-helpers
22
20
```
23
21
24
-
Note that you can also use the `str()` helper function instead of manually creating a `StringHelper` object:
22
+
Note that you can also use the `str()` helper function, which is a shorthand for `ImmutableString`:
25
23
26
24
```php
27
25
use function Tempest\Support\str;
@@ -33,24 +31,24 @@ if (! $path->startsWith('/docs')) {
33
31
}
34
32
```
35
33
36
-
The `StringHelper` encapsulates many of PHP's built-in string functions, as well as several regex-based functions. You can check out the [full API on GitHub](https://github.com/tempestphp/tempest-framework/blob/main/src/Tempest/Support/src/StringHelper.php).
34
+
These string helpers encapsulate many of PHP's built-in string functions, as well as several regex-based functions. You can check out the [full API on GitHub](https://github.com/tempestphp/tempest-framework/blob/main/src/Tempest/Support/src/Str/ManipulatesString.php).
37
35
38
36
## Arrays
39
37
40
-
The `ArrayHelper` class wraps a normal array, and provides a fluent API to manipulate it. Note that all these methods are immutable, so every call creates a new instance of `ArrayHelper` without modifying the original one.
38
+
The `ImmutableArray` and `MutableArray` classes wrap an array, and provide a fluent API to manipulate it.
41
39
42
40
```php
43
-
use Tempest\Support\ArrayHelper;
41
+
use Tempest\Support\Arr\ImmutableArray;
44
42
45
-
$items = (new ArrayHelper(glob(__DIR__ . '/Content/*.md')))
43
+
$items = (new ImmutableArray(glob(__DIR__ . '/Content/*.md')))
46
44
->reverse()
47
45
->map(function (string $path) {
48
46
// …
49
47
})
50
48
->mapTo(BlogPost::class);
51
49
```
52
50
53
-
Note that you can also use the `arr()` helper function instead of manually creating a `ArrayHelper` object:
51
+
Note that you can also use the `arr()` helper function instead of manually creating an `ImmutableArray` object:
You can check out the [full API on GitHub](https://github.com/tempestphp/tempest-framework/blob/main/src/Tempest/Support/src/ArrayHelper.php).
67
+
You can check out the [full API on GitHub](https://github.com/tempestphp/tempest-framework/blob/main/src/Tempest/Support/src/Arr/ManipulatesArray.php).
0 commit comments