From c8b36051d44aa32f3108bd7408ed294c7eea9aab Mon Sep 17 00:00:00 2001 From: otsch Date: Sun, 8 Dec 2024 15:18:39 +0100 Subject: [PATCH] Add PhpVersion class Add class `PhpVersion` to check if the PHP version is at least, or below a certain major and minor version. --- CHANGELOG.md | 4 ++++ src/PhpVersion.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/PhpVersion.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d6342a..25bb1c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2024-12-08 +### Added +* Class `PhpVersion` to check if the PHP version is at least, or below a certain major and minor version. + ## [1.1.2] - 2024-11-20 ### Fixed - Another improvement for parsing invalid JSON with unescaped double quote characters inside string values. diff --git a/src/PhpVersion.php b/src/PhpVersion.php new file mode 100644 index 0000000..4cad219 --- /dev/null +++ b/src/PhpVersion.php @@ -0,0 +1,16 @@ += $major && ($minor === null || PHP_MINOR_VERSION >= $minor); + } + + public static function isBelow(int $major, ?int $minor = null): bool + { + return !self::isAtLeast($major, $minor); + } +}