Skip to content

Commit be36e0f

Browse files
committed
LCO: Preventer class initialized and filled by strategy.
1 parent 424e70b commit be36e0f

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Overlapping/Preventer.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ class Preventer
66
{
77
private $strategy;
88

9-
public function __construct(Strategy $strategy)
9+
public function __construct($strategy)
1010
{
11-
$this->strategy = $strategy;
11+
switch ($strategy) {
12+
case 'database':
13+
$this->strategy = new DatabaseStrategy();
14+
break;
15+
16+
case 'file':
17+
default:
18+
$this->strategy = new FileStrategy();
19+
break;
20+
}
1221
}
1322
}

src/WithoutOverlapping.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminated\Console;
44

5+
use Illuminated\Console\Overlapping\Preventer;
56
use Symfony\Component\Console\Input\InputInterface;
67
use Symfony\Component\Console\Output\OutputInterface;
78

@@ -10,16 +11,7 @@ trait WithoutOverlapping
1011
protected function execute(InputInterface $input, OutputInterface $output)
1112
{
1213
$strategy = $this->getOverlappingStrategy();
13-
switch ($strategy) {
14-
case 'database':
15-
//
16-
break;
17-
18-
case 'file':
19-
default:
20-
//
21-
break;
22-
}
14+
$preventer = new Preventer($strategy);
2315

2416
return parent::execute($input, $output);
2517
}

0 commit comments

Comments
 (0)