File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -185,4 +185,20 @@ public static function makeDebugValue(mixed $value) : string
185185 default => 'instanceof ' . $ type ,
186186 };
187187 }
188+
189+ /**
190+ * Remove dots and zeros from the end of the version.
191+ *
192+ * @param string $version
193+ *
194+ * @return string
195+ */
196+ public static function roundVersion (string $ version ) : string
197+ {
198+ if (\str_ends_with ($ version , '.0 ' )) {
199+ $ version = \substr ($ version , 0 , -2 );
200+ return static ::roundVersion ($ version );
201+ }
202+ return $ version ;
203+ }
188204}
Original file line number Diff line number Diff line change 11<?php
2+
3+ use Framework \Debug \Debugger ;
4+
25/**
36 * @var array<string,Framework\Debug\Collection> $collections
47 * @var array<string,mixed> $activities
2730 </header>
2831 <div class="contents">
2932 <div class="collector-default">
30- <p>Running<?= class_exists ('Aplus ' ) ? ' Aplus ' . Aplus::VERSION
31- : '' ?> on <?= \PHP_OS_FAMILY ?> with PHP <?= \PHP_VERSION ?> </p>
33+ <p>Running<?=
34+ class_exists ('Aplus ' )
35+ ? ' Aplus ' . Debugger::roundVersion (Aplus::VERSION )
36+ : '' ?> on <?= \PHP_OS_FAMILY ?> with PHP
37+ <?= Debugger::roundVersion (\PHP_VERSION ) ?>
38+ </p>
3239 <p>★
3340 <a href="https://aplus-framework.com" target="_blank">aplus-framework.com</a>
3441 </p>
Original file line number Diff line number Diff line change @@ -205,4 +205,12 @@ public function testMakeDebugValue() : void
205205 self ::assertSame ("' \\'Ok' " , Debugger::makeDebugValue ("'Ok " ));
206206 self ::assertSame ('instanceof stdClass ' , Debugger::makeDebugValue (new \stdClass ()));
207207 }
208+
209+ public function testRoundVersion () : void
210+ {
211+ self ::assertSame ('1.2.3 ' , Debugger::roundVersion ('1.2.3 ' ));
212+ self ::assertSame ('1.0.3 ' , Debugger::roundVersion ('1.0.3 ' ));
213+ self ::assertSame ('1.2 ' , Debugger::roundVersion ('1.2.0 ' ));
214+ self ::assertSame ('1 ' , Debugger::roundVersion ('1.0.0 ' ));
215+ }
208216}
You can’t perform that action at this time.
0 commit comments