Skip to content

Commit 3374d9e

Browse files
committed
Add static "fromVersion" method
1 parent 36acb04 commit 3374d9e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Version.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ public static function fromString(string $version): self
3838
return new self($version);
3939
}
4040

41+
/**
42+
* @param VersionInterface $version
43+
* @return static
44+
*/
45+
public static function fromVersion(VersionInterface $version): self
46+
{
47+
if ($version instanceof self) {
48+
return $version;
49+
}
50+
51+
return self::fromString($version->toString());
52+
}
53+
4154
/**
4255
* {@inheritDoc}
4356
*/

0 commit comments

Comments
 (0)