Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/vendor/fidry/cpu-core-counter/src/Finder/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/vendor/fidry/cpu-core-counter/src/Finder/EnvVariableFinder.php
<?php

/*
 * This file is part of the Fidry CPUCounter Config package.
 *
 * (c) Théo FIDRY <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Fidry\CpuCoreCounter\Finder;

use function getenv;
use function preg_match;
use function sprintf;
use function var_export;

final class EnvVariableFinder implements CpuCoreFinder
{
    /** @var string */
    private $environmentVariableName;

    public function __construct(string $environmentVariableName)
    {
        $this->environmentVariableName = $environmentVariableName;
    }

    public function diagnose(): string
    {
        $value = getenv($this->environmentVariableName);

        return sprintf(
            'parse(getenv(%s)=%s)=%s',
            $this->environmentVariableName,
            var_export($value, true),
            self::isPositiveInteger($value) ? $value : 'null'
        );
    }

    public function find(): ?int
    {
        $value = getenv($this->environmentVariableName);

        return self::isPositiveInteger($value)
            ? (int) $value
            : null;
    }

    public function toString(): string
    {
        return sprintf(
            'getenv(%s)',
            $this->environmentVariableName
        );
    }

    /**
     * @param string|false $value
     */
    private static function isPositiveInteger($value): bool
    {
        return false !== $value
            && 1 === preg_match('/^\d+$/', $value)
            && (int) $value > 0;
    }
}

Spamworldpro Mini