Skip to content

Commit

Permalink
Add Version::getOriginalString(), Fixes phar-io#24
Browse files Browse the repository at this point in the history
  • Loading branch information
addshore committed Feb 22, 2021
1 parent e478261 commit f36aac0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

All notable changes to phar-io/version are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [3.0.5] - Unreleased

### Added

- [#24](https://github.com/phar-io/version/issues/24): `Version::getOriginalString()` added

## [3.0.4] - 14.12.2020

### Fixed

- [#22](https://github.com/phar-io/version/pull/22): make dev suffix rank works for uppercase too


## [3.0.3] - 30.11.2020

### Added
Expand All @@ -25,6 +30,7 @@ This release now supports PHP 7.2+ and PHP ^8.0. No other changes included.

- Internal Refactoring
- More scalar types
- `Version::getVersionString()` will no longer return `v` prefixes for any versions

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
namespace PharIo\Version;

class Version {
/** @var string */
private $originalVersionString;

/** @var VersionNumber */
private $major;

Expand All @@ -27,12 +30,17 @@ class Version {
*/
public function __construct($versionString) {
$this->ensureVersionStringIsValid($versionString);
$this->originalVersionString = $versionString;
}

public function getPreReleaseSuffix(): PreReleaseSuffix {
return $this->preReleaseSuffix;
}

public function getOriginalString(): string {
return $this->originalVersionString;
}

public function getVersionString(): string {
$str = sprintf(
'%d.%d.%d',
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public function versionProvider() {
];
}

/**
* @dataProvider versionStringProvider
*/
public function testOrigionalStringReturnsExceptedVersionString(string $input) {
$this->assertEquals(
(new Version($input))->getOriginalString(),
$input
);
}

/**
* @dataProvider versionStringProvider
*/
Expand Down

0 comments on commit f36aac0

Please sign in to comment.