<?php
/**
 * 2026 Paysera
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * @author Paysera <plugins@paysera.com>
 * @copyright 2026 Paysera
 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
 * International Registered Trademark & Property of Paysera
 */

declare(strict_types=1);

namespace Paysera\PrestashopPayments\Diagnostic\Service;

if (!defined('_PS_VERSION_')) {
    exit;
}

class PhpEnvironment
{
    public function getVersion(): string
    {
        return PHP_VERSION;
    }

    public function getMajorMinor(): string
    {
        return sprintf('%d.%d', PHP_MAJOR_VERSION, PHP_MINOR_VERSION);
    }

    public function isExtensionLoaded(string $extension): bool
    {
        return extension_loaded($extension);
    }

    public function getExtensionVersion(string $extension): ?string
    {
        $version = phpversion($extension);

        return $version === false ? null : (string) $version;
    }

    public function getIni(string $key): ?string
    {
        $value = ini_get($key);

        return $value === false ? null : (string) $value;
    }
}
