Created
July 9, 2020 04:44
-
-
Save DarkGhostHunter/0a4b5e33dc54eb927182eb03d91c5e3d to your computer and use it in GitHub Desktop.
Container class to pass through the next method.
This file contains 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 characters
<?php | |
class Container | |
{ | |
protected $target; | |
protected $value; | |
public function __construct($target, $value) | |
{ | |
$this->target = $target; | |
$this->value = $value; | |
} | |
public function __call($method, $arguments) | |
{ | |
if ($this->value) { | |
$this->{$method}(...$arguments); | |
} | |
return $this->target; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment