1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37:
<?php
namespace Teto\Object;
trait MethodAlias
{
public function __call($name, array $args)
{
if (!isset(self::$method_aliases)) {
throw new \LogicException(static::class.'::$method_aliases is not set.');
}
if (isset(self::$method_aliases[$name])) {
$method = self::$method_aliases[$name];
} elseif (in_array($name, self::$method_aliases)) {
$method = $name;
} else {
throw new \BadMethodCallException(static::class."::{$name}() is not exists.");
}
return call_user_func([$this, $method]);
}
}