| Conditions | 3 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | 2 | public function generate(ChannelInterface $channel, \DateTime $startsAt = null) |
|
| 34 | { |
||
| 35 | 2 | $targetDuration = $this->options['target_duration']; |
|
| 36 | |||
| 37 | 2 | if (null === $startsAt) { |
|
| 38 | 1 | $startsAt = new \DateTime(); |
|
| 39 | 1 | } |
|
| 40 | 2 | $segments = $this->manager->findPlaying($channel, $startsAt, $targetDuration); |
|
| 41 | 2 | $playlist = new Playlist($segments); |
|
| 42 | |||
| 43 | 2 | $first = $playlist->getFirst(); |
|
| 44 | 2 | if (null === $first) { |
|
| 45 | 1 | return; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | $age = $first->getEndsAt()->getTimestamp() - $startsAt->getTimestamp() + 1; |
|
| 49 | 1 | $playlist->setAge($age); |
|
| 50 | |||
| 51 | 1 | return new M3u8($playlist, $this->options['version'], $targetDuration, $first->getProgram()->getSequence()); |
|
| 52 | } |
||
| 53 | } |
||
| 54 |