Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit 641bb8c

Browse files
author
Andrey Helldar
committed
Updated a Symfony console command
1 parent 9e01697 commit 641bb8c

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

src/Frameworks/Symfony/Console/Sync.php

+19-27
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
namespace Helldar\EnvSync\Frameworks\Symfony\Console;
44

5-
use Helldar\EnvSync\Services\Compiler;
6-
use Helldar\EnvSync\Services\Finder;
7-
use Helldar\EnvSync\Services\Parser;
8-
use Helldar\EnvSync\Services\Stringify;
95
use Helldar\EnvSync\Services\Syncer;
10-
use Helldar\EnvSync\Support\Config;
116
use Symfony\Component\Console\Command\Command;
127
use Symfony\Component\Console\Input\InputArgument;
138
use Symfony\Component\Console\Input\InputInterface;
149
use Symfony\Component\Console\Output\OutputInterface;
15-
use Symfony\Component\Finder\Finder as SymfonyFinder;
1610

1711
final class Sync extends Command
1812
{
@@ -22,6 +16,23 @@ final class Sync extends Command
2216
/** @var \Symfony\Component\Console\Output\OutputInterface */
2317
protected $output;
2418

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+
2536
protected function execute(InputInterface $input, OutputInterface $output)
2637
{
2738
$this->input = $input;
@@ -36,17 +47,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
3647
$this->info("The found keys were successfully saved to the {$filename} file.");
3748
}
3849

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-
4750
protected function sync(string $filename): void
4851
{
49-
$this->syncer()
52+
$this->syncer
5053
->path($this->path())
5154
->filename($filename)
5255
->store();
@@ -59,7 +62,7 @@ protected function path(): string
5962

6063
protected function filename(): string
6164
{
62-
return '.env.example';
65+
return '.env.production';
6366
}
6467

6568
protected function optionPath(): ?string
@@ -72,17 +75,6 @@ protected function realPath(): string
7275
return realpath(base_path());
7376
}
7477

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-
8678
protected function info(string $message): void
8779
{
8880
$this->line($message, 'info');

0 commit comments

Comments
 (0)