Skip to content

Commit 8c20469

Browse files
WIP
1 parent 1ca1f08 commit 8c20469

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@ composer require sebastiaanluca/php-pipe-operator
5252

5353
The basic gist of the package is that it takes a value and performs one or more actions on it. A simple example:
5454

55+
```php
56+
use SebastiaanLuca\PipeOperator\Pipe;
57+
58+
Pipe::from('hello')->strtoupper()->get();
59+
60+
// "HELLO"
61+
```
62+
63+
A few alternatives to write the same:
64+
5565
```php
5666
take('hello')->strtoupper()->get();
5767

68+
// "HELLO"
69+
70+
pipe('hello')->strtoupper()->get();
71+
5872
// "HELLO"
5973
```
6074

src/functions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ function take(mixed $value): Pipe
1111
return new Pipe($value);
1212
}
1313
}
14+
15+
if (! function_exists('pipe')) {
16+
/**
17+
* Create a new piped item from a given value.
18+
*/
19+
function pipe(mixed $value): Pipe
20+
{
21+
return new Pipe($value);
22+
}
23+
}

0 commit comments

Comments
 (0)