public function __construct($param_num, $expected, $given, $search_depth = 0, $code = 0, \Exception $Previous = NULL) { $infos = \Ninaca\Utilities\Debug::whoCalledMe($search_depth); $class =& $infos['class']; $func =& $infos['function']; $file =& $infos['file']; $line =& $infos['line']; $class_func = !empty($class) ? "{$class}::{$func}()" : "{$func}()"; $msg = "{$class_func} expects parameter {$param_num} to be {$expected}, " . "{$given} given.<br />" . "This function has been called in {$file} at line {$line}.<br />" . "This exception has been thrown"; parent::__construct($msg, $code, $Previous); }
public function __construct($msg, $search_depth = 0, $code = 0, $Previous = NULL) { Debug::checkArgs(0, 1, 'string', $msg, 1, 'nonempty', $msg, 2, 'int', $search_depth, 3, 'int', $code); if ($Previous !== NULL && !$Previous instanceof \Exception) { $type = is_object($Previous) ? get_class($Previous) : gettype($Previous); throw new InvalidArgumentException(4, 'NULL or an instance of \\Exception', $type); } $this->real_message = $msg; $infos = \Ninaca\Utilities\Debug::whoCalledMe($search_depth); $class =& $infos['class']; $func =& $infos['function']; $file =& $infos['file']; $line =& $infos['line']; $class_func = !empty($class) ? "{$class}::{$func}()" : "{$func}()"; $msg = "{$class_func}: {$msg} <br/>" . "This function has been called in {$file} at line {$line}.<br />" . "This exception has been thrown"; parent::__construct($msg, $code, $Previous); }
public function loadFile($file) { Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file); if (!is_file($file) || !is_readable($file)) { throw new FtpException("{$file} is not readable or doesn’t exists."); } try { return ScYaml::load($file); } catch (\Symfony\Components\Yaml\ParserException $e) { throw new ParserException($e->getMessage()); } catch (\InvalidArgumentException $e) { throw new ParserException($e->getMessage()); } }
public function loadFile($file) { Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file); if (!is_file($file) || !is_readable($file)) { throw new FtpException("{$file} is not readable or doesn’t exists."); } try { return syck_load(file_get_contents($file)); } catch (\SyckException $e) { throw new ParserException($e->getMessage()); } }
public static function rescaleImage($w, $h, $max_w = 200, $max_h = 200, $depth = 0, $iate = 0) { Debug::checkArgs(0, 5, 'int', $depth, 6, 'int', $iate); Debug::checkArgs($iate, 1, 'int', $w, 1, array('greater than', 0), $w, 2, 'int', $h, 2, array('greater than', 0), $h, 3, 'int', $max_w, 3, array('greater than', 10), $max_w, 4, 'int', $max_h, 4, array('greater than', 10), $max_h); return self::rescaleImage_exec($w, $h, $max_w, $max_h); }
public function offsetUnset($offset) { Debug::checkArg(0, 1, 'array or string', $offset, 1, 'nonempty', $offset); if (is_array($offset)) { $config =& $this->_config; foreach ($offset as $key) { if (!isset($config[$key])) { throw new Iae("Undefined index: {$key}"); } else { if ($key == end($offset)) { unset($config[$key]); } else { $config =& $config[$key]; } } } } else { if (isset($this->_config[$offset])) { unset($this->_config[$offset]); } else { throw new Iae("Undefined index: {$offset}"); } } }