Beispiel #1
0
 public static function validateCode($courseCode)
 {
     $courseCode = trim($courseCode);
     if (!preg_match("/^[A-Z0-9]{1,10}\$/", $courseCode)) {
         throw new Exception("Course code can contain capital letters in the range of A-Z, numbers 0-9 and of length 1-10.");
     }
     if (CourseFetcher::codeExists($courseCode)) {
         throw new Exception("Course code already exists on database. Please insert a different one.");
     }
     return $courseCode;
 }