Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 31, 2024
1 parent 841f664 commit 296d340
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Runner/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public static function series(): string
return implode('.', array_slice(explode('.', $version), 0, 2));
}

public static function majorVersionNumber(): int
{
return (int) explode('.', self::series())[0];
}

public static function getVersionString(): string
{
return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.';
Expand Down
3 changes: 1 addition & 2 deletions src/TextUI/Command/Commands/VersionCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
namespace PHPUnit\TextUI\Command;

use function explode;
use function file_get_contents;
use function sprintf;
use function version_compare;
Expand All @@ -25,7 +24,7 @@ final class VersionCheckCommand implements Command
public function execute(): Result
{
$latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
$latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . explode('.', Version::series())[0]);
$latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . Version::majorVersionNumber());

$notLatest = version_compare($latestVersion, Version::id(), '>');
$notLatestCompatible = version_compare($latestCompatibleVersion, Version::id(), '>');
Expand Down

0 comments on commit 296d340

Please sign in to comment.