Skip to content

Commit

Permalink
Split artist and title on first delimiter
Browse files Browse the repository at this point in the history
Split artist and title correctly when there are multiple delimiters.
  • Loading branch information
MarkWasley authored Aug 15, 2023
1 parent 4924297 commit e399700
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Result/CurrentSong.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
string $text = '',
string $title = '',
string $artist = '',
string $delimiter = '-'
string $delimiter = ' - '
) {
$text = $this->cleanUpString($text);
$title = $this->cleanUpString($title);
Expand All @@ -35,8 +35,8 @@ public function __construct(
if (\count($string_parts) === 1) {
$title = $text;
} else {
$title = trim(array_pop($string_parts));
$artist = trim(implode($delimiter, $string_parts));
$title = trim(implode($delimiter, array_slice($string_parts, 1)));
$artist = trim($string_parts[0]);
}
}

Expand Down

0 comments on commit e399700

Please sign in to comment.