# EntryParser

> Reads the collector and panel entries an application declares in its debug configuration.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Registration](/docs/extensions/debug-core/reference/registration/index.md) › EntryParser

| final class | `PHPForge\Debug\Registration\EntryParser` |
| --- | --- |
| Source | [`src/Registration/EntryParser.php`](https://github.com/php-forge/debug-core/blob/main/src/Registration/EntryParser.php#L20) |

Reads the collector and panel entries an application declares in its debug configuration.

The three checks are separate calls, so each host keeps its own validation order and wraps every
[`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php) in the message its users already know.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`assertKeyMatchesId()`](#method-assertKeyMatchesId) static | Rejects a string registration key that differs from the ID the registered object declares. | `EntryParser` |
| [`enabled()`](#method-enabled) static | Returns the effective `enabled` flag of an entry. | `EntryParser` |
| [`parse()`](#method-parse) static | Splits one entry into the class to resolve and the options declared beside it. | `EntryParser` |

## Method details

### assertKeyMatchesId() <span id="method-assertKeyMatchesId"></span>

```php
public static function assertKeyMatchesId(int|string $key, string $id, string $kind): void
```

Rejects a string registration key that differs from the ID the registered object declares.

An integer key comes from a list entry, which names no ID and is accepted as is.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$key` | `int\|string` | Key the configuration registers the entry under. |
| `$id` | `string` | ID the registered collector or panel declares. |
| `$kind` | `string` | Entry kind named in the failure, such as `'collector'` or `'panel'`. |

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when a string key differs from the declared ID.

### enabled() <span id="method-enabled"></span>

```php
public static function enabled(array<array-key, mixed> $options, string $id): bool
```

Returns the effective `enabled` flag of an entry.

A `null` value counts as absent, as it does for [`PanelOverride::fromArray()`](/docs/extensions/debug-core/reference/registration/paneloverride/index.md#method-fromArray).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `array<array-key, mixed>` | Entry options, or a whole configuration array declaring `enabled`. |
| `$id` | `string` | Configuration ID naming the entry in a failure. |

**Returns**

`bool`: Declared flag, or `true` when the entry omits it.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when `enabled` is neither a `bool` nor `null`.

### parse() <span id="method-parse"></span>

```php
public static function parse(mixed $entry, string $id): PHPForge\Debug\Registration\ParsedEntry
```

Splits one entry into the class to resolve and the options declared beside it.

The class is not checked for existence, so a disabled entry naming an uninstalled optional package never
reaches the autoloader.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$entry` | `mixed` | Class string, or an array declaring a `class` string plus options. |
| `$id` | `string` | Configuration ID naming the entry in a failure. |

**Returns**

[`ParsedEntry`](/docs/extensions/debug-core/reference/registration/parsedentry/index.md): Class and remaining options, `enabled` included.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when the entry declares no class string.