JBZoo\SimpleTypes\Type\Type::__invoke PHP Method

__invoke() public method

public __invoke ( )
    public function __invoke()
    {
        $args = func_get_args();
        $argsCount = count($args);
        if ($argsCount === 0) {
            $this->error('Undefined arguments');
        } elseif ($argsCount === 1) {
            $rules = $this->_formatter->getList();
            if (array_key_exists($args[0], $rules)) {
                return $this->convert($args[0]);
            } else {
                return $this->set($args[0]);
            }
        } elseif ($argsCount === 2) {
            return $this->set(array($args[0], $args[1]));
        }
        throw new Exception($this->_type . ': Too many arguments');
    }