class AuditResult implements MarkupInterface, Countable (View source)

Encapsulates the result of a migration audit.

Properties

protected MigrationInterface $migration

The audited migration.

protected bool $status

The result of the audit (TRUE if passed, FALSE otherwise).

protected string[] $reasons

The reasons why the migration passed or failed the audit.

Methods

__construct(MigrationInterface $migration, bool $status, array $reasons = [])

AuditResult constructor.

getMigration()

Returns the audited migration.

bool
passed()

Returns the boolean result of the audit.

$this
addReason(string|object $reason)

Adds a reason why the migration passed or failed the audit.

static AuditResult
pass(MigrationInterface $migration, array $reasons = [])

Creates a passing audit result for a migration.

static AuditResult
fail(MigrationInterface $migration, array $reasons = [])

Creates a failing audit result for a migration.

int
count()

Implements \Countable::count() for Twig template compatibility.

string
__toString()

Returns the reasons the migration passed or failed, as a string.

string[]
jsonSerialize()

Returns the reasons the migration passed or failed, for JSON serialization.

Details

__construct(MigrationInterface $migration, bool $status, array $reasons = [])

AuditResult constructor.

Parameters

MigrationInterface $migration

The audited migration.

bool $status

The result of the audit (TRUE if passed, FALSE otherwise).

array $reasons

(optional) The reasons why the migration passed or failed the audit.

MigrationInterface getMigration()

Returns the audited migration.

Return Value

MigrationInterface

The audited migration.

bool passed()

Returns the boolean result of the audit.

Return Value

bool

The result of the audit. TRUE if the migration passed the audit, FALSE otherwise.

$this addReason(string|object $reason)

Adds a reason why the migration passed or failed the audit.

Parameters

string|object $reason

The reason to add. Can be a string or a string-castable object.

Return Value

$this

static AuditResult pass(MigrationInterface $migration, array $reasons = [])

Creates a passing audit result for a migration.

Parameters

MigrationInterface $migration

The audited migration.

array $reasons

(optional) The reasons why the migration passed the audit.

Return Value

AuditResult

static AuditResult fail(MigrationInterface $migration, array $reasons = [])

Creates a failing audit result for a migration.

Parameters

MigrationInterface $migration

The audited migration.

array $reasons

(optional) The reasons why the migration failed the audit.

Return Value

AuditResult

int count()

Implements \Countable::count() for Twig template compatibility.

Return Value

int

See also

MarkupInterface

string __toString()

Returns the reasons the migration passed or failed, as a string.

Return Value

string

The markup.

See also

MarkupInterface

string[] jsonSerialize()

Returns the reasons the migration passed or failed, for JSON serialization.

Return Value

string[]