File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 22
33namespace Illuminated \Console \Overlapping ;
44
5+ use Illuminate \Console \Command ;
6+
57class Preventer
68{
9+ private $ command ;
710 private $ strategy ;
811
9- public function __construct ($ strategy )
12+ public function __construct (Command $ command )
13+ {
14+ $ this ->command = $ command ;
15+ $ this ->strategy = $ this ->strategy ();
16+ }
17+
18+ private function strategy ()
1019 {
11- switch ($ strategy ) {
20+ if (!empty ($ this ->strategy )) {
21+ return $ this ->strategy ;
22+ }
23+
24+ switch ($ this ->command ->getOverlappingStrategy ()) {
1225 case 'database ' :
13- $ this ->strategy = new DatabaseStrategy ();
14- break ;
26+ return new DatabaseStrategy ();
1527
1628 case 'file ' :
1729 default :
18- $ this ->strategy = new FileStrategy ();
19- break ;
30+ return new FileStrategy ();
2031 }
2132 }
2233}
Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ trait WithoutOverlapping
1010{
1111 protected function execute (InputInterface $ input , OutputInterface $ output )
1212 {
13- $ strategy = $ this ->getOverlappingStrategy ();
14- $ preventer = new Preventer ($ strategy );
13+ $ preventer = new Preventer ($ this );
1514
1615 return parent ::execute ($ input , $ output );
1716 }
You can’t perform that action at this time.
0 commit comments