Updated helios and multikino classes and interface they are implementing.

This commit is contained in:
kplaczek
2018-04-05 22:38:20 +02:00
parent 46d32b2cec
commit d68020d056
4 changed files with 171 additions and 91 deletions

View File

@@ -8,35 +8,47 @@ use App\Paper\Interfaces\Cinema;
class CinemaMultikino implements Cinema
{
private $cinemaId;
private $day;
function fetchRepertorire($day, $cinemaId = null)
public function setCinemaId($cinemaId)
{
$moviePath = 'https://multikino.pl/data/filmswithshowings/' . $cinemaId;
$this->cinemaId = $cinemaId;
}
public function setDay($day)
{
$this->day = $day;
}
function fetchRepertorire()
{
if (is_null($this->cinemaId) || is_null($this->day))
throw new \Exception('Day or cinemaid not set.');
$moviePath = 'https://multikino.pl/data/filmswithshowings/' . $this->cinemaId;
$movieContent = file_get_contents($moviePath);
print_r($movieContent);
$movieJson = json_decode($movieContent, 0);
return $movieJson;
}
function parseRepertoire($day, $cinemaId = null)
function parseRepertoire()
{
$movieJson = $this->fetchRepertorire($day, $cinemaId);
$movieJson = $this->fetchRepertorire();
echo $day;
// print_r($movieJson);
$filmy = [];
foreach ($movieJson->films as $movie) {
$film = [];
$film['id'] = $movie->id;
$film['title'] = $movie->title;
$film['times'] = [];
$film['date'] = $day;
$film['date'] = $this->day;
$film['runningtime'] = $movie->info_runningtime;
$film['genres'] = [];
$film['synopsis_short'] = str_replace(["\r\n", " "], [" "], $movie->synopsis_short);
if ($movie->original_s_count > 0 && $movie->show_showings) {
foreach ($movie->showings as $shoving) {
if ($shoving->date_time == $day) {
if ($shoving->date_time == $this->day) {
foreach ($shoving->times as $time) {
$film['times'][] = $time->time . " " . $time->screen_type;
}
@@ -53,28 +65,27 @@ echo $day;
}
}
// print_r($filmy);
die();
return $filmy;
}
function convertToPrint($day, $cinemaId = null)
function convertToPrint()
{
$filmy = $this->parseRepertoire($day, $cinemaId);
$filmy = $this->parseRepertoire();
$text = '';
$text .= "Repertuar Multikino Gdańsk\n";
$text .= $day . "\n\n";
$text .= $this->day . "\n\n";
foreach ($filmy as $movie) {
$text .= $movie['title']. "\n";
$text .= '('.$movie['runningtime']. ")\n";
$text .= $movie['title'] . "\n";
$text .= '(' . $movie['runningtime'] . ")\n";
$text .= implode(', ', $movie['genres']) . "\n\n";
$text .= $movie['synopsis_short'] . "\n\n";
$text .= implode(', ', $movie['times']) . "\n";
$text .= "--------------------------------\n\n";
}
return $text;
}
}