Skip to content

Commit

Permalink
Fix Lyric inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
landrok committed Nov 27, 2020
1 parent 45e57c8 commit 2341ef3
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 47 deletions.
19 changes: 11 additions & 8 deletions src/PhpTabs/Music/Lyric.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ class Lyric
{
const REGEX = " ";

/**
* @var int
*/
private $from;

/**
* @var string
*/
private $lyrics;

public function __construct()
{
$this->from = 1;
$this->lyrics = [];
$this->lyrics = '';
}

public function getFrom(): int
Expand All @@ -36,16 +43,12 @@ public function setFrom(int $from): void
$this->from = $from;
}

public function getLyrics(): array
public function getLyrics(): string
{
return $this->lyrics;
}

/**
* @param array|string $lyrics
* @todo Fix given type either string or array
*/
public function setLyrics($lyrics): void
public function setLyrics(string $lyrics): void
{
$this->lyrics = $lyrics;
}
Expand All @@ -65,7 +68,7 @@ public function getLyricBeats(): array

public function isEmpty(): bool
{
return count($this->getLyrics()) == 0;
return strlen($this->getLyrics()) === 0;
}

public function copyFrom(Lyric $lyric): void
Expand Down
8 changes: 4 additions & 4 deletions src/PhpTabs/Writer/GuitarPro/GuitarPro5Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ private function writeLyrics(Song $song): void
}
}

$this->writeInt($lyricTrack == null ? 0 : $lyricTrack->getNumber());
$this->writeInt($lyricTrack == null ? 0 : $lyricTrack->getLyrics()->getFrom());
$this->writeInt(is_null($lyricTrack) ? 0 : $lyricTrack->getNumber());
$this->writeInt(is_null($lyricTrack) ? 0 : $lyricTrack->getLyrics()->getFrom());
$this->writeStringInteger(
$lyricTrack == null ? '' : $lyricTrack->getLyrics()->getLyrics()
is_null($lyricTrack) ? '' : $lyricTrack->getLyrics()->getLyrics()
);

for ($i = 0; $i < 4; $i++) {
$this->writeInt($lyricTrack === null ? 0 : 1);
$this->writeInt(is_null($lyricTrack) ? 0 : 1);
$this->writeStringInteger('');
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/json/testSimpleMidi.mid.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down Expand Up @@ -3304,7 +3304,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/json/testSimpleTab.gp3.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down Expand Up @@ -3262,7 +3262,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/json/testSimpleTab.gp4.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down Expand Up @@ -3262,7 +3262,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/json/testSimpleTab.gp5.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down Expand Up @@ -3262,7 +3262,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/json/testSimpleTab.mid.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down Expand Up @@ -3196,7 +3196,7 @@
},
"lyrics": {
"from": 1,
"lyrics": []
"lyrics": ""
},
"measures": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/PhpTabs/files/serialized/testSimpleMidi.mid.ser

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/PhpTabs/files/serialized/testSimpleTab.gp3.ser

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/PhpTabs/files/serialized/testSimpleTab.gp4.ser

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/PhpTabs/files/serialized/testSimpleTab.gp5.ser

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/PhpTabs/files/serialized/testSimpleTab.mid.ser

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test/PhpTabs/files/xml/testSimpleMidi.mid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down Expand Up @@ -2883,7 +2883,7 @@
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/xml/testSimpleTab.gp3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down Expand Up @@ -2904,7 +2904,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/xml/testSimpleTab.gp4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down Expand Up @@ -2904,7 +2904,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/xml/testSimpleTab.gp5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down Expand Up @@ -2904,7 +2904,7 @@ Testing comments line 2</comments>
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/xml/testSimpleTab.mid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down Expand Up @@ -2785,7 +2785,7 @@
</color>
<lyrics>
<from>1</from>
<lyrics/>
<lyrics></lyrics>
</lyrics>
<measures>
<measure>
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/yaml/testSimpleMidi.mid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ song:
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 1
Expand Down Expand Up @@ -2412,7 +2412,7 @@ song:
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 2
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/yaml/testSimpleTab.gp3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 1
Expand Down Expand Up @@ -2389,7 +2389,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 2
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/yaml/testSimpleTab.gp4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 1
Expand Down Expand Up @@ -2389,7 +2389,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 2
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/yaml/testSimpleTab.gp5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 1
Expand Down Expand Up @@ -2389,7 +2389,7 @@ Testing comments line 2"
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 2
Expand Down
4 changes: 2 additions & 2 deletions test/PhpTabs/files/yaml/testSimpleTab.mid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ song:
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 1
Expand Down Expand Up @@ -2328,7 +2328,7 @@ song:
B: 0
lyrics:
from: 1
lyrics:
lyrics: ""
measures:
measure:
channelId: 2
Expand Down

0 comments on commit 2341ef3

Please sign in to comment.