|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use Liquetsoft\Fias\Component\EntityRegistry\PhpArrayFileRegistry; |
4 | | -use Liquetsoft\Fias\Component\Helper\FileSystemHelper; |
5 | 4 | use Liquetsoft\Fias\Elastic\Generator\MapperGenerator; |
6 | 5 | use Liquetsoft\Fias\Elastic\Generator\MapperTestGenerator; |
7 | 6 | use Liquetsoft\Fias\Elastic\Generator\ModelGenerator; |
8 | 7 | use Liquetsoft\Fias\Elastic\Generator\ModelTestGenerator; |
9 | 8 | use Liquetsoft\Fias\Elastic\Generator\NormalizerGenerator; |
10 | 9 | use Liquetsoft\Fias\Elastic\Generator\SerializerGenerator; |
| 10 | +use Marvin255\FileSystemHelper\FileSystemFactory; |
11 | 11 |
|
12 | 12 | $root = dirname(__DIR__); |
13 | 13 |
|
14 | | -require_once $root . '/vendor/autoload.php'; |
| 14 | +require_once dirname(__DIR__) . '/vendor/autoload.php'; |
15 | 15 |
|
| 16 | +$fs = FileSystemFactory::create(); |
16 | 17 | $registry = new PhpArrayFileRegistry(); |
17 | 18 |
|
18 | 19 | $dir = $root . '/src/Entity'; |
19 | | -if (is_dir($dir)) { |
20 | | - FileSystemHelper::remove(new SplFileInfo($dir)); |
21 | | -} |
22 | | -mkdir($dir, 0777, true); |
| 20 | +$fs->mkdirIfNotExist($dir); |
| 21 | +$fs->emptyDir($dir); |
23 | 22 | $dirObject = new SplFileInfo($dir); |
24 | 23 | $namespace = 'Liquetsoft\\Fias\\Elastic\\Entity'; |
25 | 24 | $generator = new ModelGenerator($registry); |
26 | 25 | $generator->run($dirObject, $namespace); |
27 | 26 |
|
28 | 27 | $dir = $root . '/tests/Entity'; |
29 | | -if (is_dir($dir)) { |
30 | | - FileSystemHelper::remove(new SplFileInfo($dir)); |
31 | | -} |
32 | | -mkdir($dir, 0777, true); |
| 28 | +$fs->mkdirIfNotExist($dir); |
| 29 | +$fs->emptyDir($dir); |
33 | 30 | $dirObject = new SplFileInfo($dir); |
34 | 31 | $namespace = 'Liquetsoft\\Fias\\Elastic\\Tests\\Entity'; |
35 | 32 | $generator = new ModelTestGenerator($registry); |
36 | 33 | $generator->run($dirObject, $namespace); |
37 | 34 |
|
38 | 35 | $dir = $root . '/src/IndexMapper'; |
39 | | -if (is_dir($dir)) { |
40 | | - FileSystemHelper::remove(new SplFileInfo($dir)); |
41 | | -} |
42 | | -mkdir($dir, 0777, true); |
| 36 | +$fs->mkdirIfNotExist($dir); |
| 37 | +$fs->emptyDir($dir); |
43 | 38 | $dirObject = new SplFileInfo($dir); |
44 | 39 | $namespace = 'Liquetsoft\\Fias\\Elastic\\IndexMapper'; |
45 | 40 | $generator = new MapperGenerator($registry); |
46 | 41 | $generator->run($dirObject, $namespace); |
47 | 42 |
|
48 | 43 | $dir = $root . '/tests/IndexMapper'; |
49 | | -if (is_dir($dir)) { |
50 | | - FileSystemHelper::remove(new SplFileInfo($dir)); |
51 | | -} |
52 | | -mkdir($dir, 0777, true); |
| 44 | +$fs->mkdirIfNotExist($dir); |
| 45 | +$fs->emptyDir($dir); |
53 | 46 | $dirObject = new SplFileInfo($dir); |
54 | 47 | $namespace = 'Liquetsoft\\Fias\\Elastic\\Tests\\IndexMapper'; |
55 | 48 | $generator = new MapperTestGenerator($registry); |
56 | 49 | $generator->run($dirObject, $namespace); |
57 | 50 |
|
58 | 51 | $dir = new SplFileInfo($root . '/src/Serializer'); |
59 | | -if (is_dir($dir)) { |
60 | | - FileSystemHelper::remove(new SplFileInfo($dir)); |
61 | | -} |
62 | | -mkdir($dir, 0777, true); |
| 52 | +$fs->mkdirIfNotExist($dir); |
| 53 | +$fs->emptyDir($dir); |
63 | 54 | $namespace = 'Liquetsoft\\Fias\\Elastic\\Serializer'; |
64 | 55 | $generator = new SerializerGenerator($registry); |
65 | 56 | $generator->run($dir, $namespace); |
|
0 commit comments