Files
nhgooi.nl/app/Models/Track.php
T
root 30893eb7a7
Build and Deploy / build (push) Failing after 44s
Changes by CLaude
2026-08-18 09:31:05 -01:00

65 lines
1.6 KiB
PHP
Executable File

<?php
namespace Model;
class Track extends Model {
public $start;
public $itemCode;
public $title;
public $artist;
public $duration;
public $ends;
public $isLayout;
public function __construct($data) {
// Convert arrays to objects for consistent handling
if(is_array($data)) {
$data = (object) $data;
}
parent::__construct($data);
// Ensure string fields are not arrays
if(is_array($this->title)) {
$this->title = $this->title[0] ?? '';
}
if(is_array($this->itemCode)) {
$this->itemCode = $this->itemCode[0] ?? '';
}
if(is_array($this->artist)) {
$this->artist = $this->artist[0] ?? '';
}
parent::ConvertToDateTime($this->start);
parent::ConvertToDateTime($this->ends);
$isLayout = $this->isLayout();
}
private static $IDENTS = ['UURSLUITER' => 'Nieuws', 'NIEUWSOPEN ' => 'Nieuws', 'ANWB' => 'Verkeersinformatie', 'REGIO' => 'Regionieuws', 'CB' => 'Reclame'];
public function isLayout() {
foreach(self::$IDENTS as $ident => $display) {
if(substr($this->itemCode, 0, strlen($ident)) == $ident || substr($this->title, 0, strlen($ident)) == $ident) {
$this->title = $display;
$this->artist = "";
$this->itemCode = '_' . $this->itemCode;
return false;
}
}
if(strlen($this->itemCode) > 0 && ($this->itemCode[0] == 'V')) {
return true;
}
return false;
}
public function ends($ends = null) {
$this->ends = $ends;
}
public function secondsRemaining() {
return ($this->ends) ? ($this->ends->getTimestamp() - time()) : -1;
}
}