Skip to content

Commit

Permalink
Merge pull request #97 from jolicode/os-helper-replacement
Browse files Browse the repository at this point in the history
Deprecate OsHelper in favor of jolicode/php-os-helper
  • Loading branch information
pyrech authored Dec 3, 2023
2 parents 4d02d96 + 4884579 commit 1416a31
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.2', '8.3']
composer-flags: ['']
name: ['']
include:
- php-version: 8.0
- php-version: 8.1
composer-flags: '--prefer-lowest'
name: '(prefer lowest dependencies)'
steps:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes between versions

## Not yet released

* Deprecated Joli\JoliNotif\Util\OsHelper in favor of jolicode/php-os-helper package
* Added support for Symfony 7.x
* Added support for PHP 8.3
* Dropped support for PHP 8.0

## 2.5.2 (2023-05-24)

* Added PHAR to GitHub releases
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
}
},
"require": {
"php": ">=8.0",
"symfony/process": "^5.4 || ^6.0"
"php": ">=8.1",
"jolicode/php-os-helper": "^0.1.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.13",
"symfony/finder": "^5.4 || ^6.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0"
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0"
},
"bin": [
"jolinotif"
Expand Down
4 changes: 1 addition & 3 deletions src/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@

namespace Joli\JoliNotif\Exception;

interface Exception
{
}
interface Exception {}
2 changes: 1 addition & 1 deletion src/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Joli\JoliNotif;

use Joli\JoliNotif\Util\OsHelper;
use Joli\JoliNotif\Util\PharExtractor;
use JoliCode\PhpOsHelper\OsHelper;

class Notification
{
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/AppleScriptNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Joli\JoliNotif\Notifier;

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;

/**
* This notifier can be used on Mac OS X 10.9+.
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/CliBasedNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Joli\JoliNotif\Exception\InvalidNotificationException;
use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Notifier;
use Joli\JoliNotif\Util\OsHelper;
use Joli\JoliNotif\Util\PharExtractor;
use JoliCode\PhpOsHelper\OsHelper;
use Symfony\Component\Process\Process;

abstract class CliBasedNotifier implements Notifier
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/NotifuNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Joli\JoliNotif\Notifier;

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;

/**
* This notifier can be used on Windows Seven and provides its own binaries if
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/SnoreToastNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Joli\JoliNotif\Notifier;

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;
use Symfony\Component\Process\Process;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/TerminalNotifierNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Joli\JoliNotif\Notifier;

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;

/**
* This notifier can be used on Mac OS X 10.8, or higher, using the
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier/ToasterNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Joli\JoliNotif\Notifier;

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;

/**
* This notifier can be used on Windows Eight and higher and provides its own
Expand Down
2 changes: 1 addition & 1 deletion src/NotifierFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Joli\JoliNotif\Notifier\NullNotifier;
use Joli\JoliNotif\Notifier\SnoreToastNotifier;
use Joli\JoliNotif\Notifier\TerminalNotifierNotifier;
use Joli\JoliNotif\Util\OsHelper;
use JoliCode\PhpOsHelper\OsHelper;

class NotifierFactory
{
Expand Down
65 changes: 5 additions & 60 deletions src/Util/OsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,9 @@

namespace Joli\JoliNotif\Util;

use Symfony\Component\Process\Process;
use JoliCode\PhpOsHelper\OsHelper as BaseOsHelper;

class OsHelper
{
private static string $kernelName;
private static string $kernelVersion;
private static string $macOSVersion;

public static function isUnix(): bool
{
return '/' === \DIRECTORY_SEPARATOR;
}

public static function isWindowsSubsystemForLinux(): bool
{
return self::isUnix() && false !== mb_strpos(strtolower(php_uname()), 'microsoft');
}

public static function isWindows(): bool
{
return '\\' === \DIRECTORY_SEPARATOR;
}

public static function isWindowsSeven(): bool
{
if (!isset(self::$kernelVersion)) {
self::$kernelVersion = php_uname('r');
}

return '6.1' === self::$kernelVersion;
}

public static function isWindowsEightOrHigher(): bool
{
if (!isset(self::$kernelVersion)) {
self::$kernelVersion = php_uname('r');
}

return version_compare(self::$kernelVersion, '6.2', '>=');
}

public static function isMacOS(): bool
{
if (!isset(self::$kernelName)) {
self::$kernelName = php_uname('s');
}

return str_contains(self::$kernelName, 'Darwin');
}

public static function getMacOSVersion(): string
{
if (!isset(self::$macOSVersion)) {
$process = new Process(['sw_vers', '-productVersion']);
$process->run();
self::$macOSVersion = trim($process->getOutput());
}

return self::$macOSVersion;
}
}
/**
* @deprecated since 2.6, use OsHelper from jolicode/php-os-helper instead
*/
class OsHelper extends BaseOsHelper {}

0 comments on commit 1416a31

Please sign in to comment.