Skip to content

Commit bc98bdf

Browse files
committed
Added toString().
1 parent aad011d commit bc98bdf

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/VersionParser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Mistralys\VersionParser\Parser\NumberDetector;
1616
use Mistralys\VersionParser\Parser\ShortTags;
1717
use Mistralys\VersionParser\Parser\TagWeights;
18+
use Stringable;
1819

1920
/**
2021
* Version number parsing utility: parses version numbers,
@@ -47,7 +48,7 @@
4748
* @package VersionParser
4849
* @author Sebastian Mordziol <s.mordziol@mistralys.eu>
4950
*/
50-
class VersionParser
51+
class VersionParser implements Stringable
5152
{
5253
public const TAG_TYPE_NONE = 'none';
5354
public const TAG_TYPE_BETA = 'beta';
@@ -520,4 +521,9 @@ public function getSeparatorChar() : string
520521
{
521522
return $this->separator;
522523
}
524+
525+
public function __toString() : string
526+
{
527+
return $this->getTagVersion();
528+
}
523529
}

src/VersionTag.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
use Mistralys\VersionParser\Parser\ShortTags;
88
use Mistralys\VersionParser\Parser\TagWeights;
9+
use Stringable;
910

10-
class VersionTag
11+
class VersionTag implements Stringable
1112
{
1213
private string $tagName;
1314
private int $number;
@@ -168,4 +169,9 @@ public function toArray() : array
168169
'normalized' => $this->getNormalized()
169170
);
170171
}
172+
173+
public function __toString() : string
174+
{
175+
return $this->getNormalized();
176+
}
171177
}

0 commit comments

Comments
 (0)