File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change 3030use PhpBg \DvbPsi \Tables \Eit ;
3131use PhpBg \DvbPsi \Tables \EitEvent ;
3232use PhpBg \DvbPsi \Tables \Identifier ;
33- use PhpBg \DvbPsi \Tables \Values \EitRunningStatus ;
3433
3534/**
3635 * Class EitServiceAggregator
@@ -125,23 +124,26 @@ public function add(Eit $eit): bool
125124 }
126125
127126 /**
128- * Return current running event
127+ * Return running event at a specified timestamp, which defaults to now
129128 *
130129 * @return EitEvent|null
130+ * @param int $timestamp
131131 */
132- public function getRunningEvent ()
132+ public function getRunningEvent (int $ timestamp = null )
133133 {
134- if (empty ( $ this -> followingEvents )) {
135- return null ;
134+ if (! isset ( $ timestamp )) {
135+ $ timestamp = time () ;
136136 }
137- $ runningStatus = EitRunningStatus::RUNNING ();
138- foreach ($ this ->followingEvents as $ eitevent ) {
139- /**
140- * @var EitEvent $eit
141- */
142- if ($ runningStatus ->equals ($ eitevent ->getRunningStatus ())) {
143- return $ eitevent ;
137+ foreach ($ this ->getAllEvents () as $ event ) {
138+ if ($ event ->startTimestamp > $ timestamp ) {
139+ // Future event
140+ continue ;
141+ }
142+ if ($ event ->startTimestamp + $ event ->duration < $ timestamp ) {
143+ // Past event
144+ continue ;
144145 }
146+ return $ event ;
145147 }
146148 return null ;
147149 }
You can’t perform that action at this time.
0 commit comments