# HasIntegrity

> Provides an immutable API for the integrity attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › HasIntegrity

| trait | `UIAwesome\Html\Attribute\HasIntegrity` |
| --- | --- |
| Source | [`src/HasIntegrity.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/HasIntegrity.php#L19) |

Used by 2 types:

- [`UIAwesome\Html\Metadata\Link`](/docs/extensions/html/reference/metadata/link/index.md)
- [`UIAwesome\Html\Metadata\Script`](/docs/extensions/html/reference/metadata/script/index.md)

Provides an immutable API for the `integrity` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/integrity>, <https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`integrity()`](#method-integrity) | Sets the `integrity` attribute. | `HasIntegrity` |

## Method details

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

```php
public function integrity(string|Stringable|UnitEnum|null $value): static
```

Sets the `integrity` attribute.

Provides the Subresource Integrity hash for the resource.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Integrity metadata, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `integrity` attribute.