Esempio n. 1
0
 /** 
  * Return a random value from a given array or object. 
  * @param array || object
  * @return string random value
  */
 public static function random($data = false)
 {
     if ($data) {
         if (Validate::isObject($data)) {
             $data = Format::objectToArray($data);
         }
         if (Validate::isArray($data)) {
             return $data[array_rand($data, 1)];
         }
     }
     return false;
 }
Esempio n. 2
0
 /** 
  * Stack custom config on top of default config to get a complete config array.  
  * If isset static $config, use it to prevent loading a file over and over again. 
  * @param use params to move deeper into array 
  * @return array with merged config 
  */
 private static function getConfig()
 {
     if (!isset(self::$config)) {
         $default = Format::jsonToArray(File::get('../config/default.config.json'));
         $custom = Format::jsonToArray(File::get('../config/custom.config.json'));
         if ($default && $custom) {
             self::$config = self::merge($default, $custom);
         } else {
             if ($default) {
                 self::$config = $default;
             }
         }
     }
     if (isset(self::$config)) {
         return self::$config;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Echo JSON and exit. 
  * @param mixed input
  * @param boolean exit after displaying JSON? 
  * @return boolean 
  */
 public static function json($input = false, $exit = true)
 {
     if ($input) {
         echo Format::toJson($input);
         if ($exit) {
             exit;
         }
     }
     return false;
 }