---
title: "PhpRulesDriver – API-Referenz · Quittio"
description: "Built-in PHP rules: levels L1 (structure), L2 (profile), L3 (business rules) and L7 (plausibility)."
canonical_url: "https://quittio.dev/docs/api/Quittio/Core/Validation/Drivers/PhpRulesDriver"
locale: de
meta:
  "og:description": "Built-in PHP rules: levels L1 (structure), L2 (profile), L3 (business rules) and L7 (plausibility)."
  "og:image": "https://quittio.dev/og/quittio-de.jpg"
  "og:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "PhpRulesDriver – API-Referenz · Quittio"
  "twitter:image": "https://quittio.dev/og/quittio-de.jpg"
  "twitter:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

[API reference](https://quittio.dev/docs/api) / [Quittio](https://quittio.dev/docs/api/Quittio) \\ [Core](https://quittio.dev/docs/api/Quittio/Core) \\ [Validation](https://quittio.dev/docs/api/Quittio/Core/Validation) \\ [Drivers](https://quittio.dev/docs/api/Quittio/Core/Validation/Drivers)

# PhpRulesDriver

final class in quittio/core · implements [`ValidationDriver`](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationDriver)

`Quittio\Core\Validation\Drivers\PhpRulesDriver` · [Source](https://github.com/Quittio/quittio/blob/v0.7.1/packages/core/src/Validation/Drivers/PhpRulesDriver.php#L32)

Built-in PHP rules: levels L1 (structure), L2 (profile), L3 (business rules) and L7 (plausibility).

Rules of the profile and of the country packs are added per invoice.

## Methods \#

| Method | Description |
| --- | --- |
| `->__construct()` | |
| `->knownCodes()` | Every rule and finding code this driver can report with the given profiles and country packs (without the overrides), e.g. to check configured overrides for typing errors. |
| `->levels()` | |
| `->name()` | |
| `->overrides()` | The rule overrides of this driver. |
| `->rules()` | The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs without those the profile replaces (ReplacesRules), then the additional rules. |
| `->supports()` | |
| `->validate()` | |
| `->withLevels()` | The same driver (additional rules, VAT identifier verifier, overrides) with other levels. |
| `->withOverrides()` | The same driver with other rule overrides (rules switched off, re-rated or replaced). |
| `->withVatIdVerifier()` | The same driver with an online VAT identifier check (e.g. VIES). |

### `__construct()`#

```
public function __construct(
    list<Rule> $additionalRules = [],
    ?VatIdVerifier $vatIdVerifier = null,
    list<ValidationLevel> $levels = [\Quittio\Core\Validation\ValidationLevel::L1, \Quittio\Core\Validation\ValidationLevel::L2, \Quittio\Core\Validation\ValidationLevel::L3, \Quittio\Core\Validation\ValidationLevel::L7],
    RuleOverrides $overrides = new \Quittio\Core\Validation\RuleOverrides(),
)
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$additionalRules` | `list< [Rule](https://quittio.dev/docs/api/Quittio/Core/Validation/Rule)>` = `[]` | |
| `$vatIdVerifier` | `? [VatIdVerifier](https://quittio.dev/docs/api/Quittio/Core/Validation/Plausibility/VatIdVerifier)` = `null` | |
| `$levels` | `list< [ValidationLevel](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationLevel)>` = `[\Quittio\Core\Validation\ValidationLevel::L1, \Quittio\Core\Validation\ValidationLevel::L2, \Quittio\Core\Validation\ValidationLevel::L3, \Quittio\Core\Validation\ValidationLevel::L7]` | levels to run; L7 can be switched off |
| `$overrides` | `[RuleOverrides](https://quittio.dev/docs/api/Quittio/Core/Validation/RuleOverrides)` = `new \Quittio\Core\Validation\RuleOverrides()` | rules switched off, re-rated or replaced by code |

### `knownCodes()`#

```
public function knownCodes(
    iterable<Profile> $profiles,
    iterable<CountryPack> $packs,
): list<string>
```

Every rule and finding code this driver can report with the given profiles and country packs (without the overrides), e.g. to check configured overrides for typing errors.

| Parameter | Type | Description |
| --- | --- | --- |
| `$profiles` | `iterable< [Profile](https://quittio.dev/docs/api/Quittio/Core/Profiles/Profile)>` | |
| `$packs` | `iterable< [CountryPack](https://quittio.dev/docs/api/Quittio/Core/Countries/CountryPack)>` | |

<dl><dt>Returns</dt>
<dd><code>list&lt;string&gt;</code></dd>
</dl>

### `levels()`#

```
public function levels(): array
```

<dl><dt>Returns</dt>
<dd><code>array</code></dd>
</dl>

### `name()`#

```
public function name(): string
```

<dl><dt>Returns</dt>
<dd><code>string</code></dd>
</dl>

### `overrides()`#

```
public function overrides(): RuleOverrides
```

The rule overrides of this driver.

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Validation/RuleOverrides">RuleOverrides</a></code></dd>
</dl>

### `rules()`#

```
public function rules(ValidationSubject $subject): list<Rule>
```

The rules for the subject after the overrides: the built-in rules, those of the profile and the country packs without those the profile replaces (ReplacesRules), then the additional rules.

| Parameter | Type | Description |
| --- | --- | --- |
| `$subject` | `[ValidationSubject](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationSubject)` | |

<dl><dt>Returns</dt>
<dd><code>list&lt;<a href="https://quittio.dev/docs/api/Quittio/Core/Validation/Rule">Rule</a>&gt;</code></dd>
</dl>

### `supports()`#

```
public function supports(ValidationSubject $subject): bool
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$subject` | `[ValidationSubject](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationSubject)` | |

<dl><dt>Returns</dt>
<dd><code>bool</code></dd>
</dl>

### `validate()`#

```
public function validate(ValidationSubject $subject): ValidationResult
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$subject` | `[ValidationSubject](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationSubject)` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationResult">ValidationResult</a></code></dd>
</dl>

### `withLevels()`#

```
public function withLevels(list<ValidationLevel> $levels): self
```

The same driver (additional rules, VAT identifier verifier, overrides) with other levels.

| Parameter | Type | Description |
| --- | --- | --- |
| `$levels` | `list< [ValidationLevel](https://quittio.dev/docs/api/Quittio/Core/Validation/ValidationLevel)>` | |

<dl><dt>Returns</dt>
<dd><code>self</code></dd>
</dl>

### `withOverrides()`#

```
public function withOverrides(RuleOverrides $overrides): self
```

The same driver with other rule overrides (rules switched off, re-rated or replaced).

| Parameter | Type | Description |
| --- | --- | --- |
| `$overrides` | `[RuleOverrides](https://quittio.dev/docs/api/Quittio/Core/Validation/RuleOverrides)` | |

<dl><dt>Returns</dt>
<dd><code>self</code></dd>
</dl>

### `withVatIdVerifier()`#

```
public function withVatIdVerifier(?VatIdVerifier $verifier): self
```

The same driver with an online VAT identifier check (e.g. VIES).

| Parameter | Type | Description |
| --- | --- | --- |
| `$verifier` | `? [VatIdVerifier](https://quittio.dev/docs/api/Quittio/Core/Validation/Plausibility/VatIdVerifier)` | |

<dl><dt>Returns</dt>
<dd><code>self</code></dd>
</dl>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/#website","@type":"WebSite","description":"E-Rechnungen für PHP und Laravel: ZUGFeRD, XRechnung und Peppol erstellen, prüfen, lesen und archivieren.","inLanguage":"de-DE","name":"Quittio","url":"https://quittio.dev/","publisher":{"@id":"https://quittio.dev/#identity"},"workTranslation":{"@id":"https://quittio.dev/en#website"}},{"@id":"https://quittio.dev/docs/api/Quittio/Core/Validation/Drivers/PhpRulesDriver#webpage","@type":"WebPage","description":"Built-in PHP rules: levels L1 (structure), L2 (profile), L3 (business rules) and L7 (plausibility).","name":"PhpRulesDriver – API-Referenz","url":"https://quittio.dev/docs/api/Quittio/Core/Validation/Drivers/PhpRulesDriver","isPartOf":{"@id":"https://quittio.dev/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/docs/api/Quittio/Core/Validation/Drivers/PhpRulesDriver"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"de-DE","url":"https://quittio.dev/logo.png"}]}
```