Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (50 sloc) 849 Bytes
<?php
trait Codable
{
public function code()
{
echo 'I can code';
}
}
trait Testable
{
public function test()
{
echo 'I can test';
}
}
class Human
{
public function talk()
{
echo 'I can talk';
}
public static function canDo()
{
$message = '';
$methods = get_class_methods(static::class);
foreach ($methods as $method) {
if ($method == __FUNCTION__) {
continue;
}
$message .= " `$method`";
}
echo static::class.' can do:'.$message.PHP_EOL;
}
}
class Developer extends Human
{
use Codable;
}
class Tester extends Human
{
use Testable;
}
class SuperMan extends Human
{
use Codable, Testable;
}
Human::canDo();
Developer::canDo();
Tester::canDo();
SuperMan::canDo();