Files
BloomPatched/build/scripts/Targets/TargetDescriptionFiles/Module.php

43 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Targets\TargetDescriptionFiles;
require_once __DIR__ . "/RegisterGroup.php";
class Module
{
public ?string $key = null;
public ?string $name = null;
public ?string $description = null;
/** @var RegisterGroup[] */
public array $registerGroups = [];
public function __construct(
?string $key,
?string $name,
?string $description,
array $registerGroups,
) {
$this->key = $key;
$this->name = $name;
$this->description = $description;
$this->registerGroups = $registerGroups;
}
public function getRegisterGroup(array|string $keys): ?RegisterGroup
{
if (is_string($keys)) {
$keys = explode('.', $keys);
}
2024-02-12 19:39:21 +00:00
$firstLevelSubgroupKey = array_shift($keys);
foreach ($this->registerGroups as $registerGroup) {
2024-02-12 19:39:21 +00:00
if ($registerGroup->key === $firstLevelSubgroupKey) {
return !empty($keys) ? $registerGroup->getSubgroup($keys) : $registerGroup;
}
}
return null;
}
}