Skip to content

Commit 51b5a11

Browse files
WIP
1 parent 8c20469 commit 51b5a11

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pipe('hello')->strtoupper()->get();
7575
Of course that's not very useful since you could've just used `strtoupper('hello')` and be done with it, but the goal is to make multi-method calls on a value easier to read and write:
7676

7777
```php
78-
$subdomain = take('https://blog.sebastiaanluca.com')
78+
$subdomain = Pipe::from('https://blog.sebastiaanluca.com')
7979
->parse_url()
8080
->end()
8181
->explode('.', PIPED_VALUE)
@@ -88,19 +88,19 @@ $subdomain = take('https://blog.sebastiaanluca.com')
8888
Note that in comparison to the original RFC, there's no need to pass the initial value to methods that receive the value as first parameter and have no other required parameters. The previous value is always passed as first parameter. In effect, both of the following examples will work:
8989

9090
```php
91-
take('hello')->strtoupper()->get();
91+
Pipe::from('hello')->strtoupper()->get();
9292

9393
// "HELLO"
9494

95-
take('hello')->strtoupper(PIPED_VALUE)->get();
95+
Pipe::from('hello')->strtoupper(PIPED_VALUE)->get();
9696

9797
// "HELLO"
9898
```
9999

100100
In contrast, if a method takes e.g. a setting before the previous value, we need to set it manually using the replacement identifier (the globally available `PIPED_VALUE` constant). This identifier can be placed *anywhere* in the method call, it will simply be replaced by the previous value.
101101

102102
```php
103-
take(['key' => 'value'])
103+
Pipe::from(['key' => 'value'])
104104
->array_search('value', PIPED_VALUE)
105105
->get();
106106

@@ -112,7 +112,7 @@ take(['key' => 'value'])
112112
Sometimes standard methods don't cut it and you need to perform a custom operation on a value in the process. You can do so using a closure:
113113

114114
```php
115-
take('string')
115+
Pipe::from('string')
116116
->pipe(fn(string $value): string => 'prefixed-' . $value)
117117
->get();
118118

@@ -128,7 +128,7 @@ class MyClass
128128
{
129129
public function __construct()
130130
{
131-
take('HELLO')
131+
Pipe::from('HELLO')
132132
->pipe($this)->lowercase()
133133
->get();
134134

@@ -158,7 +158,7 @@ class MyClass
158158
{
159159
public function __construct()
160160
{
161-
take('HELLO')
161+
Pipe::from('HELLO')
162162
->pipe([$this, 'lowercase'])
163163
->get();
164164

@@ -186,7 +186,7 @@ class MyClass
186186
{
187187
public function __construct()
188188
{
189-
take('HELLO')
189+
Pipe::from('HELLO')
190190
->pipe(Closure::fromCallable([$this, 'lowercase']))
191191
->get();
192192

0 commit comments

Comments
 (0)