Created
April 26, 2016 10:25
-
-
Save matsu-chara/b203978ed269f14393ca5781c8799722 to your computer and use it in GitHub Desktop.
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 | |
abstract class Mofu { | |
abstract protected function isNyan(); | |
public function mofureyo() { | |
if($this->isNyan() === true) { | |
return "mofure"; | |
} else { | |
return "mofuruna"; | |
} | |
} | |
} | |
trait Nyan { | |
protected function isNyan() { | |
return true; | |
} | |
} | |
class MofuImpl extends Mofu { | |
use Nyan; | |
} | |
echo "普通のコード\n"; | |
$mofu = new MofuImpl(); | |
echo $mofu->mofureyo()."\n"; | |
trait MockNyan { | |
protected function isNyan() { | |
return false; | |
} | |
} | |
class MockMofuImpl extends Mofu { | |
use MockNyan; | |
} | |
echo "テストコード\n"; | |
$mofu = new MockMofuImpl(); | |
echo $mofu->mofureyo()."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment