コード例 #1
0
 /**
  * A function to update a faucet's status (active or paused)
  * according to their low-balance status and if the
  * faucet's URL is error-free and valid.
  */
 public static function checkUpdateStatuses()
 {
     //Retrieve faucets to be updated.
     $faucets = Faucet::all();
     $pausedFaucets = [];
     $activatedFaucets = [];
     foreach ($faucets as $f) {
         if (UrlValidation::urlExists($f->url) != true && $f->is_paused == false && $f->has_low_balance == false) {
             $f->is_paused = true;
             $f->save();
             array_push($pausedFaucets, $f->name);
         } elseif (UrlValidation::urlExists($f->url) != false && $f->is_paused == true && $f->has_low_balance == false) {
             $f->is_paused = false;
             $f->save();
             array_push($activatedFaucets, $f->name);
         }
     }
     if (count($pausedFaucets) == 0 && count($activatedFaucets) == 0) {
         Session::flash('success_message_update_faucet_statuses_none', 'No faucets have been updated.');
     }
     if (count($pausedFaucets) > 0) {
         Session::flash('success_message_update_faucet_statuses_paused', 'The following faucets have been paused: ' . implode(",", $pausedFaucets));
     }
     if (count($activatedFaucets) > 0) {
         Session::flash('success_message_update_faucet_statuses_activated', 'The following faucets have been activated: ' . implode(",", $activatedFaucets));
     }
 }
コード例 #2
0
 /**
  * WebsiteMeta constructor.
  * @param $url
  * @throws Exception
  */
 public function __construct($url)
 {
     if (UrlValidation::urlExists($url) == true) {
         $this->url = $url;
     } else {
         throw new Exception('The URL does not exist or is experiencing technical issues.');
     }
 }
コード例 #3
0
 private function generateUrlMatchesSyntaxTest($url, $regex, $exp_result)
 {
     $result = UrlValidation::urlMatchesSyntax($url, $regex);
     $this->assertEquals($exp_result, $result);
 }