Last active
January 15, 2020 14:30
-
-
Save imliam/11940ab73b024140f8e7cd76ef56b0e0 to your computer and use it in GitHub Desktop.
Revisions
-
imliam revised this gist
Feb 24, 2018 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,11 @@ public function __construct($value) $this->id = '__pipe-' . uniqid(); $GLOBALS[$this->id] = $value; } public function __destruct() { unset($GLOBALS[$this->id]); } public function pipe($value) { -
imliam created this gist
Feb 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <?php if (! function_exists('take')) { /** * Run functions consecutively by piping through the result of one * into the next. * * @param mixed $value A value * * @return object */ function take($value) { return new class($value) { public function __construct($value) { $this->id = '__pipe-' . uniqid(); $GLOBALS[$this->id] = $value; } public function pipe($value) { $GLOBALS[$this->id] = $value; return $this; } public function __get($name) { if ($name === 'value') { return $GLOBALS[$this->id]; } trigger_error("Property '$name' doesn't exist and cannot be gotten", E_USER_ERROR); } }; } }