Your IP : 216.73.216.158


Current Path : /home/rtorresani/www/vendor/allure-framework/allure-phpunit/src/Internal/
Upload File :
Current File : //home/rtorresani/www/vendor/allure-framework/allure-phpunit/src/Internal/DefaultThreadDetector.php

<?php

declare(strict_types=1);

namespace Qameta\Allure\PHPUnit\Internal;

use Qameta\Allure\PHPUnit\Setup\ThreadDetectorInterface;

use function gethostname;

/**
 * Supported parallel runners:
 *
 * - Paratest {@link https://github.com/paratestphp/paratest}
 *
 * @internal
 */
final class DefaultThreadDetector implements ThreadDetectorInterface
{
    private string|false|null $hostName = null;

    public function getThread(): ?string
    {
        /** @var mixed $token */
        $token = $_ENV['TEST_TOKEN'] ?? null;

        return isset($token)
            ? (string) $token
            : null;
    }

    public function getHost(): ?string
    {
        $this->hostName ??= @gethostname();

        return false === $this->hostName ? null : $this->hostName;
    }
}