*/ private array $applied; /** * Construct the result. * * @param SchemaVersion $startVersion Schema version before the run. * @param SchemaVersion $endVersion Schema version after the run. * @param list $applied Migrations executed, in order. */ public function __construct( SchemaVersion $startVersion, SchemaVersion $endVersion, array $applied ) { $this->startVersion = $startVersion; $this->endVersion = $endVersion; $this->applied = array_values( $applied ); } /** * Schema version installed before the run began. */ public function startVersion(): SchemaVersion { return $this->startVersion; } /** * Schema version installed after the run completed. * * Equal to {@see self::startVersion()} when no migrations were * pending; otherwise equal to the target version of the last * successfully-applied migration. */ public function endVersion(): SchemaVersion { return $this->endVersion; } /** * Ordered list of migrations applied during the run. * * Entries appear in execution order (ascending target version). * * @return list */ public function applied(): array { return $this->applied; } /** * Number of migrations applied during the run. * * Convenience for callers that only need the count (activation * logging, `"applied N migrations"` style messages). */ public function appliedCount(): int { return count( $this->applied ); } /** * Report whether the run applied zero migrations. * * True when the schema was already at (or beyond) the highest * registered target version before the run began. */ public function isNoop(): bool { return $this->applied === array(); } /** * Report whether the run advanced the schema version. * * Logical inverse of {@see self::isNoop()}; exposed as an explicit * method so call sites read naturally (`if ( $result->didAdvance() )`). */ public function didAdvance(): bool { return $this->applied !== array(); } /** * Human-readable descriptions of every applied migration. * * Returns each migration's {@see Migration::description()} in * execution order, suitable for logging or diagnostics surfaces. * * @return list */ public function appliedDescriptions(): array { return array_map( static fn ( Migration $migration ): string => $migration->description(), $this->applied ); } /** * Target versions of every applied migration, in execution order. * * Returned as bare integers (rather than {@see SchemaVersion} * instances) because the primary consumers — log lines, diagnostics * JSON, test assertions — all want the numeric value directly. * * @return list */ public function appliedVersions(): array { return array_map( static fn ( Migration $migration ): int => $migration->targetVersion()->toInt(), $this->applied ); } }