JBZoo\SimpleTypes\Formatter::getList PHP Method

getList() public method

public getList ( boolean $keysOnly = false ) : array
$keysOnly boolean
return array
    public function getList($keysOnly = false)
    {
        if ($keysOnly) {
            $keys = array_keys($this->_rules);
            return array_combine($keys, $keys);
        }
        return $this->_rules;
    }

Usage Example

Beispiel #1
0
 /**
  * @return $this
  * @throws \JBZoo\SimpleTypes\Exception
  */
 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');
 }