public function loadFile($file, array $vars = array()) { Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file); $file = realpath($file); if (!$file || !is_readable($file) || !is_file($file)) { throw new FtpException("The file {$file} is not readable."); } if (!in_array($file, $this->_loadedFiles)) { $this->_loadedFiles[] = $file; $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext === 'yml' || $ext === 'yaml') { $conf = Parsers\Yaml\Factory::factory()->loadFile($file); } if ($ext === 'ini') { $conf = parse_ini_file($file, true); } else { if ($ext === 'php') { $conf = (include $file); } } $this->_importFiles($conf); if ($this->_vars || $vars) { $conf = $this->parseConf($conf, $vars ? $vars : $this->_vars); } if (!empty($this->_config)) { $this->_config = Arrays::arrayMergeRec($this->_config, $conf); } else { $this->_config = $conf; } } }
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); }