Last active
December 21, 2015 20:58
-
-
Save Arakaki/6364642 to your computer and use it in GitHub Desktop.
Functional\Invoke.phpのテスト
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 characters
| <?php | |
| include './Functional/_import.php'; | |
| use Functional as F; | |
| class User{ | |
| private $status = false; | |
| private $name = ""; | |
| function __construct($name="",$status=true){ | |
| $this->name = $name; | |
| $this->status = $status; | |
| } | |
| public function setStatus($status){ | |
| $this->status = $status; | |
| } | |
| public function getStatus(){ | |
| return $this->status; | |
| } | |
| } | |
| $oden = new User("oden",true); | |
| $captain = new User("captain",true); | |
| echo "おでんのステータス :"; | |
| var_dump($oden->getStatus()); | |
| echo "キャプテンのステータス :"; | |
| var_dump($captain->getStatus()); | |
| $users = array($oden,$captain); | |
| //users配列の値を取り出し、その値(オブジェクト)にsetStatusメソッドがあれば | |
| //第三引数array(false) をsetStatusの引数として実行する | |
| F\invoke($users, 'setStatus', array(false)); | |
| echo "おでんのステータス :"; | |
| var_dump($oden->getStatus()); | |
| echo "キャプテンのステータス :"; | |
| var_dump($captain->getStatus()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment