Created
August 28, 2013 10:49
-
-
Save Arakaki/6364757 to your computer and use it in GitHub Desktop.
Functional/InvokeIf.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 $name = ""; | |
function __construct($name=""){ | |
$this->name = $name; | |
} | |
public function getName(){ | |
return $this->name; | |
} | |
} | |
$oden = new User("oden"); | |
$oden_name = F\invoke_if($user, 'getName', array(), false); | |
if($oden_name){ | |
var_dump("UserにはgetNameが定義されています"); | |
}else{ | |
var_dump("UserにはgetNameが定義されていません"); | |
} | |
$oden_gender = F\invoke_if($user, 'getGender', array(), false); | |
if($oden_gender){ | |
var_dump("UserにはgetGenderが定義されています"); | |
}else{ | |
var_dump("UserにはgetGenderが定義されていません"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment