123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?php
- declare(strict_types=1);
- namespace Doctrine\Migrations\Version;
- use DateTimeImmutable;
- use Doctrine\DBAL\Schema\Schema;
- use Doctrine\Migrations\Query\Query;
- use RuntimeException;
- use Throwable;
- use function count;
- /**
- * The ExecutionResult class is responsible for storing the result of a migration version after it executes.
- *
- * @internal
- */
- final class ExecutionResult
- {
- /** @var Query[] */
- private $sql = [];
- /**
- * Seconds
- *
- * @var float|null
- */
- private $time;
- /** @var float|null */
- private $memory;
- /** @var bool */
- private $skipped = false;
- /** @var bool */
- private $error = false;
- /** @var Throwable|null */
- private $exception;
- /** @var DateTimeImmutable|null */
- private $executedAt;
- /** @var int */
- private $state;
- /** @var Schema|null */
- private $toSchema;
- /** @var Version */
- private $version;
- /** @var string */
- private $direction;
- public function __construct(Version $version, string $direction = Direction::UP, ?DateTimeImmutable $executedAt = null)
- {
- $this->executedAt = $executedAt;
- $this->version = $version;
- $this->direction = $direction;
- }
- public function getDirection(): string
- {
- return $this->direction;
- }
- public function getExecutedAt(): ?DateTimeImmutable
- {
- return $this->executedAt;
- }
- public function setExecutedAt(DateTimeImmutable $executedAt): void
- {
- $this->executedAt = $executedAt;
- }
- public function getVersion(): Version
- {
- return $this->version;
- }
- public function hasSql(): bool
- {
- return count($this->sql) !== 0;
- }
- /**
- * @return Query[]
- */
- public function getSql(): array
- {
- return $this->sql;
- }
- /**
- * @param Query[] $sql
- */
- public function setSql(array $sql): void
- {
- $this->sql = $sql;
- }
- public function getTime(): ?float
- {
- return $this->time;
- }
- public function setTime(float $time): void
- {
- $this->time = $time;
- }
- public function getMemory(): ?float
- {
- return $this->memory;
- }
- public function setMemory(float $memory): void
- {
- $this->memory = $memory;
- }
- public function setSkipped(bool $skipped): void
- {
- $this->skipped = $skipped;
- }
- public function isSkipped(): bool
- {
- return $this->skipped;
- }
- public function setError(bool $error, ?Throwable $exception = null): void
- {
- $this->error = $error;
- $this->exception = $exception;
- }
- public function hasError(): bool
- {
- return $this->error;
- }
- public function getException(): ?Throwable
- {
- return $this->exception;
- }
- public function setToSchema(Schema $toSchema): void
- {
- $this->toSchema = $toSchema;
- }
- public function getToSchema(): Schema
- {
- if ($this->toSchema === null) {
- throw new RuntimeException('Cannot call getToSchema() when toSchema is null.');
- }
- return $this->toSchema;
- }
- public function getState(): int
- {
- return $this->state;
- }
- public function setState(int $state): void
- {
- $this->state = $state;
- }
- }
|