File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,23 @@ composer require sebastiaanluca/php-pipe-operator
5252
5353The 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
5666take('hello')->strtoupper()->get();
5767
68+ // "HELLO"
69+
70+ pipe('hello')->strtoupper()->get();
71+
5872// "HELLO"
5973```
6074
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments