Use foreach for episode action strings, update variable names

This commit is contained in:
Jonathan Flueren 2021-08-24 13:09:43 +02:00 committed by thrillfall
parent cd17ad5079
commit e6637a0201
1 changed files with 7 additions and 6 deletions

View File

@ -8,20 +8,21 @@ class EpisodeActionReader {
const EPISODEACTION_IDENTIFIER = 'EpisodeAction{';
/**
* @param string $episodeActionString
* @param string $episodeActionsString
* @return EpisodeAction[]
*/
public function fromString(string $episodeActionString): array {
public function fromString(string $episodeActionsString): array {
$episodeActions = [];
$episodeActionStrings = explode(self::EPISODEACTION_IDENTIFIER, $episodeActionString);
$episodeActionStrings = explode(self::EPISODEACTION_IDENTIFIER, $episodeActionsString);
array_shift($episodeActionStrings);
for($i = 1; $i < count($episodeActionStrings); $i++) {
foreach($episodeActionStrings as $episodeActionString) {
preg_match(
'/EpisodeAction{(podcast=\')(?<podcast>.*?)(\', episode=\')(?<episode>.*?)(\', action=)(?<action>.*?)(, timestamp=)(?<timestamp>.*?)(, started=)(?<started>.*?)(, position=)(?<position>.*?)(, total=)(?<total>.*?)}]*/',
self::EPISODEACTION_IDENTIFIER . $episodeActionStrings[$i],
self::EPISODEACTION_IDENTIFIER . $episodeActionString,
$matches
);