mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
2b660785e9
5a4111e518
Bump composer dependencies (#3208)
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Fidry CPUCounter Config package.
|
|
*
|
|
* (c) Théo FIDRY <theo.fidry@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
declare (strict_types=1);
|
|
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
|
|
|
|
use function defined;
|
|
use function sprintf;
|
|
final class SkipOnWindowsFinder implements CpuCoreFinder
|
|
{
|
|
/**
|
|
* @var CpuCoreFinder
|
|
*/
|
|
private $decoratedFinder;
|
|
public function __construct(CpuCoreFinder $decoratedFinder)
|
|
{
|
|
$this->decoratedFinder = $decoratedFinder;
|
|
}
|
|
public function diagnose() : string
|
|
{
|
|
return self::skip() ? 'Windows platform detected (PHP_WINDOWS_VERSION_MAJOR is set).' : $this->decoratedFinder->diagnose();
|
|
}
|
|
public function find() : ?int
|
|
{
|
|
return self::skip() ? null : $this->decoratedFinder->find();
|
|
}
|
|
public function toString() : string
|
|
{
|
|
return sprintf('SkipOnWindowsFinder(%s)', $this->decoratedFinder->toString());
|
|
}
|
|
private static function skip() : bool
|
|
{
|
|
// Skip if on Windows. Rely on PHP to detect the platform
|
|
// rather than reading the platform name or others.
|
|
return defined('PHP_WINDOWS_VERSION_MAJOR');
|
|
}
|
|
}
|