Пример #1
0
 /**
  * @return array of strings
  */
 public function getTablesAfterMovie(\model\MovieSuggestion $movie, $url)
 {
     $tables = array();
     $restaurantPage = $this->makeRequest($url);
     $dom = $this->getDomDocument($restaurantPage);
     $xpath = new \DOMXPath($dom);
     $freeTables = $xpath->query('//input[@type="radio"]');
     foreach ($freeTables as $table) {
         /**
          * First three letters of the radio buttons value represent the day
          * Last four represent the time interval (XXYY is XX to YY)
          */
         $value = $table->getAttribute('value');
         if (substr($value, 0, 3) === "fre" && $movie->getDay() === "Friday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
         if (substr($value, 0, 3) === "lor" && $movie->getDay() === "Saturday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
         if (substr($value, 0, 3) === "son" && $movie->getDay() === "Sunday") {
             if (intval(substr($value, 3, 2)) > intval($movie->getTime())) {
                 $tables[] = substr($value, 3, 2) . " och " . substr($value, 5, 2);
             }
         }
     }
     return $tables;
 }