Exemple #1
0
 /**
  *Due to repeating code thoroughly every single method, decided to simplify all of those
  *validations in this method. This method checks that:
  *1. The first argument (namely the class name) is not empty
  *2. That the class exists
  *3. That the second argument is also not empty
  *It is of course used inside this very same class due to it's internal nature. 
  *@return Int -1 if the first argument is not a string 
  *@return Int -2 if the first argument is an empty string
  *@return Int -3 if the class doesn't exists
  *@return Int -4 if the second argument is not a string
  *@return Int -5 if the second argument is an empty string
  */
 public static function parameterValidation($name)
 {
     if (!is_string($name)) {
         return -1;
     }
     if (\apf\validate\String::isEmpty($name)) {
         return -2;
     }
     if (!class_exists($name)) {
         return -3;
     }
     return TRUE;
 }
Exemple #2
0
 protected static function imperativeValidation($curValue, $exCode, $msg, array $codesAndMessages = array())
 {
     self::validateUserSuppliedExceptionCode($exCode);
     if (sizeof($codesAndMessages)) {
         $codesAndMessages = array_merge(self::getStandardExceptionMessages(), $codesAndMessages);
     } else {
         $codesAndMessages = self::getStandardExceptionMessages();
     }
     foreach ($codesAndMessages as $cam) {
         if ($cam["value"] === $curValue) {
             $_msg = \apf\validate\String::isEmpty($msg) ? $cam["msg"] : $msg;
             $ex = isset($cam["exception"]) ? $cam["exception"] : "\\InvalidArgumentException";
             throw new $ex($_msg);
         }
     }
 }