1 | <?php |
||
21 | class FileRepository implements RepositoryInterface |
||
22 | { |
||
23 | /** |
||
24 | * Migrations file name format. This format will be used when requesting new migration filename. |
||
25 | */ |
||
26 | const FILENAME_FORMAT = '{timestamp}_{chunk}_{name}.php'; |
||
27 | |||
28 | /** |
||
29 | * Timestamp format for files. |
||
30 | */ |
||
31 | const TIMESTAMP_FORMAT = 'Ymd.His'; |
||
32 | |||
33 | /** |
||
34 | * @var MigrationsConfig |
||
35 | */ |
||
36 | private $config = null; |
||
37 | |||
38 | /** |
||
39 | * Required when multiple migrations added at once. |
||
40 | * |
||
41 | * @var int |
||
42 | */ |
||
43 | private $chunkID = 0; |
||
44 | |||
45 | /** |
||
46 | * @invisible |
||
47 | * @var TokenizerInterface |
||
48 | */ |
||
49 | protected $tokenizer = null; |
||
50 | |||
51 | /** |
||
52 | * @invisible |
||
53 | * @var FactoryInterface |
||
54 | */ |
||
55 | protected $factory = null; |
||
56 | |||
57 | /** |
||
58 | * @invisible |
||
59 | * @var FilesInterface |
||
60 | */ |
||
61 | protected $files = null; |
||
62 | |||
63 | /** |
||
64 | * @param MigrationsConfig $config |
||
65 | * @param TokenizerInterface $tokenizer |
||
66 | * @param FilesInterface $files |
||
67 | * @param FactoryInterface $factory |
||
68 | */ |
||
69 | public function __construct( |
||
81 | |||
82 | /** |
||
83 | * {@inheritdoc} |
||
84 | */ |
||
85 | public function getMigrations(): array |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function registerMigration(string $name, string $class, string $body = null): string |
||
153 | |||
154 | /** |
||
155 | * Internal method to fetch all migration filenames. |
||
156 | */ |
||
157 | private function getFiles(): \Generator |
||
172 | |||
173 | /** |
||
174 | * Request new migration filename based on user input and current timestamp. |
||
175 | * |
||
176 | * @param string $name |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | private function createFilename(string $name): string |
||
194 | } |