# AuditNormalizer

> Normalizes GHSA and CVE advisory identifiers and the string lists attached to audit findings.

[API reference](/docs/api/index.md) › [Foxy](/docs/extensions/foxy/reference/index.md) › [Audit](/docs/extensions/foxy/reference/audit/index.md) › AuditNormalizer

| final class | `Foxy\Audit\AuditNormalizer` |
| --- | --- |
| Source | [`src/Audit/AuditNormalizer.php`](https://github.com/php-forge/foxy/blob/main/src/Audit/AuditNormalizer.php#L17) |

Normalizes GHSA and CVE advisory identifiers and the string lists attached to audit findings.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`isCveId()`](#method-isCveId) static | Returns whether the value is a CVE identifier, matched case-insensitively. | `AuditNormalizer` |
| [`normalizeGhsaId()`](#method-normalizeGhsaId) static | Returns the canonical GHSA identifier (uppercase prefix, lowercase segments), or `null` if the value is not a bare GHSA identifier. | `AuditNormalizer` |
| [`normalizeGhsaReference()`](#method-normalizeGhsaReference) static | Returns the canonical GHSA identifier of a bare GHSA identifier or a `https://github.com/advisories/` URL with an optional trailing slash, or `null` if the value is neither. | `AuditNormalizer` |
| [`uniqueSorted()`](#method-uniqueSorted) static | Returns the values without duplicates, sorted in ascending order and reindexed as a list. | `AuditNormalizer` |

## Method details

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

```php
public static function isCveId(string $value): bool
```

Returns whether the value is a CVE identifier, matched case-insensitively.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Candidate identifier, already trimmed by the caller. |

**Returns**

`bool`

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

```php
public static function normalizeGhsaId(string $value): string|null
```

Returns the canonical GHSA identifier (uppercase prefix, lowercase segments), or `null` if the value is not a bare
GHSA identifier.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Candidate identifier, already trimmed by the caller. |

**Returns**

`string|null`

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

```php
public static function normalizeGhsaReference(string $value): string|null
```

Returns the canonical GHSA identifier of a bare GHSA identifier or a `https://github.com/advisories/` URL with an
optional trailing slash, or `null` if the value is neither.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Candidate identifier or advisory URL. |

**Returns**

`string|null`

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

```php
public static function uniqueSorted(list<string> $values): list<string>
```

Returns the values without duplicates, sorted in ascending order and reindexed as a list.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$values` | `list<string>` | Values to deduplicate and sort. |

**Returns**

`list<string>`