@@ -53,7 +53,7 @@ public function greaterThan(?string $version = null): void
5353 $ installedVersion = $ this ->installedVersion ->getInstalledVersion ();
5454
5555 if (!$ this ->comparator ->greaterThan ($ version , $ installedVersion )) {
56- throw new UnsupportedVersionException (\sprintf (
56+ throw new UnsupportedVersionException ($ this -> getFormattedMessage (
5757 'Installed RoadRunner version `%s` not supported. Requires version `%s` or higher. ' ,
5858 $ installedVersion ,
5959 $ version
@@ -72,7 +72,7 @@ public function lessThan(string $version): void
7272 $ installedVersion = $ this ->installedVersion ->getInstalledVersion ();
7373
7474 if (!$ this ->comparator ->lessThan ($ version , $ installedVersion )) {
75- throw new UnsupportedVersionException (\sprintf (
75+ throw new UnsupportedVersionException ($ this -> getFormattedMessage (
7676 'Installed RoadRunner version `%s` not supported. Requires version `%s` or lower. ' ,
7777 $ installedVersion ,
7878 $ version
@@ -91,11 +91,32 @@ public function equal(string $version): void
9191 $ installedVersion = $ this ->installedVersion ->getInstalledVersion ();
9292
9393 if (!$ this ->comparator ->equal ($ version , $ installedVersion )) {
94- throw new UnsupportedVersionException (\sprintf (
94+ throw new UnsupportedVersionException ($ this -> getFormattedMessage (
9595 'Installed RoadRunner version `%s` not supported. Requires version `%s`. ' ,
9696 $ installedVersion ,
9797 $ version
9898 ), $ installedVersion , $ version );
9999 }
100100 }
101+
102+ /**
103+ * @param non-empty-string $message
104+ * @param non-empty-string $installedVersion
105+ * @param non-empty-string $version
106+ *
107+ * @return non-empty-string
108+ */
109+ private function getFormattedMessage (string $ message , string $ installedVersion , string $ version ): string
110+ {
111+ \preg_match ('/\bv?(\d+)\.(\d+)\.(\d+)\b/ ' , $ version , $ matches );
112+
113+ if (!empty ($ matches [0 ])) {
114+ $ version = $ matches [1 ] . '. ' . $ matches [2 ] . '. ' . $ matches [3 ];
115+ }
116+
117+ /** @var non-empty-string $msg */
118+ $ msg = \sprintf ($ message , $ installedVersion , $ version );
119+
120+ return $ msg ;
121+ }
101122}
0 commit comments