Skip to content

Commit

Permalink
Add PhpVersion class
Browse files Browse the repository at this point in the history
Add class `PhpVersion` to check if the PHP version is at least, or below
a certain major and minor version.
  • Loading branch information
otsch committed Dec 8, 2024
1 parent 89d58f4 commit c8b3605
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions src/PhpVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Crwlr\Utils;

class PhpVersion
{
public static function isAtLeast(int $major, ?int $minor = null): bool
{
return PHP_MAJOR_VERSION >= $major && ($minor === null || PHP_MINOR_VERSION >= $minor);
}

public static function isBelow(int $major, ?int $minor = null): bool
{
return !self::isAtLeast($major, $minor);
}
}

0 comments on commit c8b3605

Please sign in to comment.