forkbb/app/Models/ManagerModel.php
2018-03-08 19:39:54 +07:00

54 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace ForkBB\Models;
use ForkBB\Models\Model;
class ManagerModel extends Model
{
/**
* @var array
*/
protected $repository = [];
public function get($key)
{
return isset($this->repository[$key]) ? $this->repository[$key] : null;
}
public function set($key, $value)
{
$this->repository[$key] = $value;
return $this;
}
/**
* Возвращает action по его имени
*
* @param string $name
*
* @return mixed
*/
public function __get($name)
{
$key = \str_replace(['ForkBB\\Models\\', 'ForkBB\\', '\\'], '', \get_class($this));
return $this->c->{$key . $name}->setManager($this);
}
/**
* Выполняет подгружаемый метод при его наличии
*
* @param string $name
* @param array $args
*
* @return mixed
*/
public function __call($name, array $args)
{
$key = \str_replace(['ForkBB\\Models\\', 'ForkBB\\', '\\'], '', \get_class($this));
return $this->c->{$key . \ucfirst($name)}->setManager($this)->$name(...$args);
}
}