2
2
3
3
namespace Helldar \EnvSync \Frameworks \Symfony \Console ;
4
4
5
- use Helldar \EnvSync \Services \Compiler ;
6
- use Helldar \EnvSync \Services \Finder ;
7
- use Helldar \EnvSync \Services \Parser ;
8
- use Helldar \EnvSync \Services \Stringify ;
9
5
use Helldar \EnvSync \Services \Syncer ;
10
- use Helldar \EnvSync \Support \Config ;
11
6
use Symfony \Component \Console \Command \Command ;
12
7
use Symfony \Component \Console \Input \InputArgument ;
13
8
use Symfony \Component \Console \Input \InputInterface ;
14
9
use Symfony \Component \Console \Output \OutputInterface ;
15
- use Symfony \Component \Finder \Finder as SymfonyFinder ;
16
10
17
11
final class Sync extends Command
18
12
{
@@ -22,6 +16,23 @@ final class Sync extends Command
22
16
/** @var \Symfony\Component\Console\Output\OutputInterface */
23
17
protected $ output ;
24
18
19
+ protected $ syncer ;
20
+
21
+ public function __construct (Syncer $ syncer )
22
+ {
23
+ parent ::__construct ();
24
+
25
+ $ this ->syncer = $ syncer ;
26
+ }
27
+
28
+ protected function configure ()
29
+ {
30
+ $ this
31
+ ->setName ('env:sync ' )
32
+ ->setDescription ('Synchronizing environment settings with a preset ' )
33
+ ->addOption ('path ' , null , InputArgument::OPTIONAL , 'Gets the path to scan for files ' );
34
+ }
35
+
25
36
protected function execute (InputInterface $ input , OutputInterface $ output )
26
37
{
27
38
$ this ->input = $ input ;
@@ -36,17 +47,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
36
47
$ this ->info ("The found keys were successfully saved to the {$ filename } file. " );
37
48
}
38
49
39
- protected function configure ()
40
- {
41
- $ this
42
- ->setName ('env:sync ' )
43
- ->setDescription ('Synchronizing environment settings with a preset ' )
44
- ->addOption ('path ' , InputArgument::OPTIONAL , 'Gets the path to scan for files ' );
45
- }
46
-
47
50
protected function sync (string $ filename ): void
48
51
{
49
- $ this ->syncer ()
52
+ $ this ->syncer
50
53
->path ($ this ->path ())
51
54
->filename ($ filename )
52
55
->store ();
@@ -59,7 +62,7 @@ protected function path(): string
59
62
60
63
protected function filename (): string
61
64
{
62
- return '.env.example ' ;
65
+ return '.env.production ' ;
63
66
}
64
67
65
68
protected function optionPath (): ?string
@@ -72,17 +75,6 @@ protected function realPath(): string
72
75
return realpath (base_path ());
73
76
}
74
77
75
- protected function syncer (): Syncer
76
- {
77
- $ parser = new Parser ();
78
- $ stringify = new Stringify ();
79
- $ config = new Config ();
80
- $ compiler = new Compiler ($ stringify , $ config );
81
- $ finder = new Finder (SymfonyFinder::create ());
82
-
83
- return new Syncer ($ parser , $ compiler , $ finder );
84
- }
85
-
86
78
protected function info (string $ message ): void
87
79
{
88
80
$ this ->line ($ message , 'info ' );
0 commit comments