コード例 #1
0
 /**
  * Checks if object is an instance of class specified.<p>
  *
  * @param  object  $value     any type of value that needs to be checked.
  * @param  String  $class     class vaue is being validated as
  * @param  string  $message   name of value being passed, used in error message.
  * @param  bool    $letReturn will determine if it throws an PummelHeadException or returns true.
  * @return bool  will either return false if not and on success will return true if allowed.
  */
 public static function isClass($value, $class, $message, $letReturn = false)
 {
     if (!is_a($value, $class)) {
         if (!$letReturn) {
             ErrorsUtil::error("{$message} must be an instance of {$class}.", ServiceCodes::SERVICE_ERROR);
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
コード例 #2
0
 /**
  * gets config object from config xml
  */
 public static function getConfig()
 {
     $xml = null;
     if (file_exists(dirname(__FILE__) . "/../config.xml")) {
         $xml = simplexml_load_file(dirname(__FILE__) . "/../config.xml", "Config");
         if ($xml == null) {
             ErrorsUtil::error("Failed to convert to Config object", -1);
         }
     } else {
         ErrorsUtil::error("Can't find config", -2);
     }
     return $xml;
 }
コード例 #3
0
ファイル: Logger.php プロジェクト: retrogamer4ever/php-tools
 /**
  * Log Message that will be written to the location specified.<p>
  *
  * Will first create a special log message with the date and time in it,
  * After this is done will check if file exists in the "location" you
  * specified. If can't find file, will throw an BREException.
  *
  * @param int    $code    code error code related to "message"
  * @param string $message describing the cause of the error
  */
 public function message($code, $message)
 {
     $logMsg = date("m-d-y h:m:s") . " Code:" . $code . " Log: " . $message . "\r\n";
     if (file_exists($this->m_FullPath)) {
         $handler = fopen($this->m_FullPath, "a");
         fwrite($handler, $logMsg);
         fclose($handler);
     } else {
         ErrorsUtil::error("Can't find log file at " . $this->m_FullPath, ServiceCodes::LOGGER_ERROR);
     }
 }