Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Breyta;
class Migration
{
/** @var string */
public $file;
/** @var \DateTime */
public $executed;
/** @var string */
public $status;
/** @var string|array|Execution[] */
public $executions;
/** @var double */
public $executionTime;
public function __construct()
{
if (!empty($this->executed) && is_string($this->executed)) {
$this->executed = new \DateTime($this->executed, new \DateTimeZone('UTC'));
}
if (!empty($this->executions) && is_string($this->executions)) {
$this->executions = array_map(function ($data) {
return Execution::createInstance($data);
}, json_decode($this->executions, true));
}
}
public static function createInstance(array $data = []): self
{
$new = new static;
foreach ($data as $key => $value) {
$new->$key = $value;
}
$new->__construct();
return $new;
}
}