Пример #1
0
 private static function checkArgs_check($num, $type, $arg, $iate)
 {
     $iate += 1;
     $types = array('int', 'integer', 'string', 'char', 'nonempty', 'ressource', 'string or array', 'array or string');
     if (!is_array($type) && !in_array($type, $types)) {
         throw new Iate($i, 'an existing type', $type);
     }
     if (($type === 'int' || $type === 'integer') && !Misc::isInt($arg)) {
         throw new Iate($num, 'int', gettype($arg), $iate);
     } else {
         if ($type === 'string' && !is_string($arg)) {
             throw new Iate($num, 'string', gettype($arg), $iate);
         } else {
             if ($type === 'char' && !is_string($arg) && mb_strlen($arg) > 1) {
                 throw new Iate($num, 'char', gettype($arg), $iate);
             } else {
                 if ($type === 'nonempty' && Misc::isEmpty($arg)) {
                     throw new Iate($num, 'nonempty', 'empty value', $iate);
                 } else {
                     if ($type === 'ressource' && !$arg) {
                         throw new Iate($num, 'ressource', gettype($arg), $iate);
                     } else {
                         if (($type === 'string or array' || $type === 'array or string') && !is_string($arg) && !is_array($arg)) {
                             throw new Iate($num, 'string or array', gettype($arg), $iate);
                         } else {
                             if (is_array($type) && count($type) == 2 && isset($type[0], $type[1])) {
                                 self::checkArgs_checkArray($num, $type, $arg, $iate);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 public static function checkFilesExtension($filename, array $exts, $value_if_empty = true, $depth = 0, $iate = 0)
 {
     Debug::checkArgs(0, 4, 'int', $depth, 4, array('greater than', -1), $depth, 5, 'int', $iate, 5, array('greater than', -1), $iate);
     Debug::checkArgs($iate, 1, 'string', $filename);
     if (Misc::isEmpty($exts)) {
         return (bool) $value_if_empty;
     }
     foreach ($exts as $ext) {
         if (mb_substr($filename, -mb_strlen($ext)) === $ext) {
             return true;
         }
     }
     return false;
 }