humbug /
box
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the box project. |
||
| 7 | * |
||
| 8 | * (c) Kevin Herrera <[email protected]> |
||
| 9 | * Théo Fidry <[email protected]> |
||
| 10 | * |
||
| 11 | * This source file is subject to the MIT license that is bundled |
||
| 12 | * with this source code in the file LICENSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | namespace KevinGH\Box\Composer\Package; |
||
| 16 | |||
| 17 | use function key; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @private |
||
| 21 | */ |
||
| 22 | final readonly class RequiredItem |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 23 | { |
||
| 24 | private const POLYFILL_MAP = [ |
||
| 25 | 'paragonie/sodium_compat' => 'libsodium', |
||
| 26 | 'phpseclib/mcrypt_compat' => 'mcrypt', |
||
| 27 | ]; |
||
| 28 | |||
| 29 | private const SYMFONY_POLYFILL_REGEX = '/symfony\/polyfill-(?<extension>.+)/'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param array<string, string> $packageInfo |
||
| 33 | */ |
||
| 34 | public function __construct(private array $packageInfo) |
||
| 35 | { |
||
| 36 | } |
||
| 37 | |||
| 38 | public function getName(): string |
||
| 39 | { |
||
| 40 | return key($this->packageInfo); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function getRequiredExtensions(): Extensions |
||
| 44 | { |
||
| 45 | return PackageInfo::parseExtensions($this->packageInfo); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function getPolyfilledExtension(): ?Extension |
||
| 49 | { |
||
| 50 | $name = $this->getName(); |
||
| 51 | |||
| 52 | return Extension::tryToParsePolyfill($name); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |