File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
99### Added
1010
1111- Added support for PHP 8
12+ - Added static constructor
1213
1314### Changed
1415
Original file line number Diff line number Diff line change @@ -15,12 +15,17 @@ public function __construct(mixed $value)
1515 }
1616 }
1717
18+ public static function from ($ value ): self
19+ {
20+ return new self ($ value );
21+ }
22+
1823 public function __call (string $ name , array $ arguments ): mixed
1924 {
2025 return $ this ->pipe ($ name , ...$ arguments );
2126 }
2227
23- public function pipe (callable |object |string $ callback , mixed ...$ arguments ): Item |PipeProxy
28+ public function pipe (callable |object |string $ callback , mixed ...$ arguments ): self |PipeProxy
2429 {
2530 if (! is_callable ($ callback )) {
2631 return new PipeProxy ($ this , $ callback );
Original file line number Diff line number Diff line change 44
55use Closure ;
66use PHPUnit \Framework \TestCase ;
7+ use SebastiaanLuca \PipeOperator \Item ;
78
89class MethodsTest extends TestCase
910{
11+ /**
12+ * @test
13+ */
14+ public function it can transform using the static constructor (): void
15+ {
16+ $ result = Item::from ('https://blog.github.com ' )
17+ ->parse_url ()
18+ ->end ()
19+ ->explode ('. ' , PIPED_VALUE )
20+ ->reset ()
21+ ->get ();
22+
23+ $ this ->assertSame ('blog ' , $ result );
24+ }
25+
1026 /**
1127 * @test
1228 */
You can’t perform that action at this time.
0 commit comments