Skip to content

Instantly share code, notes, and snippets.

@Arakaki
Created August 28, 2013 10:49
Show Gist options
  • Save Arakaki/6364757 to your computer and use it in GitHub Desktop.
Save Arakaki/6364757 to your computer and use it in GitHub Desktop.
Functional/InvokeIf.phpのサンプル
<?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