php-extension-check/src/Extension/ExtensionMap.php

72 lines
1.7 KiB
PHP
Raw Normal View 히스토리

2021-05-08 22:50:26 +00:00
<?php
2022-05-25 10:10:23 +00:00
declare(strict_types=1);
2021-05-08 22:50:26 +00:00
namespace Fbrinker\ExtensionCheck\Extension;
class ExtensionMap
{
/** @var array<string,string> */
public $classes;
/** @var array<string,string> */
public $functions;
/** @var array<string,string> */
public $constants;
/** @var array<string,array<string,string[]>> */
public $dependencies;
/** @var string[] */
public $unchecked;
/**
* @param array<string,string> $classes
* @param array<string,string> $functions
* @param array<string,string> $constants
* @param array<string,array<string,string[]>> $dependencies
* @param string[] $unchecked
*/
public function __construct(
array $classes = [],
array $functions = [],
array $constants = [],
array $dependencies = [],
array $unchecked = []
) {
$this->classes = $classes;
$this->functions = $functions;
$this->constants = $constants;
$this->dependencies = $dependencies;
$this->unchecked = $unchecked;
}
2021-05-08 23:57:02 +00:00
public function checkClass(string $class): ?string
{
return $this->classes[$class] ?? null;
}
public function checkFunction(string $function): ?string
{
return $this->functions[$function] ?? null;
}
public function checkConstant(string $constant): ?string
{
return $this->constants[$constant] ?? null;
}
/**
* @return string[]
*/
public function checkRequiredDependency(string $extension): array
{
if (!isset($this->dependencies[$extension]['required'])) {
return [];
}
return $this->dependencies[$extension]['required'];
}
2021-05-08 22:50:26 +00:00
}