コード例 #1
0
ファイル: Query.php プロジェクト: tunnela/query
 /**
  * Used to escape scalar or attach escape callable.
  *
  * @param  scalar|callable $callable Scalar to escape or callable for escaping.
  * @return string|null
  */
 public static function escape($callable)
 {
     if ($callable === null) {
         return Expression::_('NULL');
     } else {
         if (is_scalar($callable)) {
             return static::$_escaper ? call_user_func(static::$_escaper, $callable) : $callable;
         } else {
             if (is_callable($callable)) {
                 static::$_escaper = $callable;
             } else {
                 throw new \Exception("Given argument is not callable nor scalar.");
             }
         }
     }
 }