first version

This commit is contained in:
Bastian Allgeier
2019-01-13 23:17:34 +01:00
commit 01277f79f2
595 changed files with 82913 additions and 0 deletions

38
kirby/src/Cms/HasMethods.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
namespace Kirby\Cms;
trait HasMethods
{
/**
* All registered methods
*
* @var array
*/
public static $methods = [];
/**
* Calls a registered method class with the
* passed arguments
*
* @param string $method
* @param array $args
* @return mixed
*/
public function callMethod(string $method, array $args = [])
{
return static::$methods[$method]->call($this, ...$args);
}
/**
* Checks if the object has a registered method
*
* @param string $method
* @return boolean
*/
public function hasMethod(string $method): bool
{
return isset(static::$methods[$method]) === true;
}
}