Completed
Push — 2.2 ( 313882...96fd92 )
by David
12s
created
src/Mouf/Utils/Patcher/Commands/AbstractApplyAllCommand.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -12,81 +12,81 @@
 block discarded – undo
12 12
 
13 13
 class AbstractApplyAllCommand extends Command
14 14
 {
15
-    /**
16
-     * @var PatchService
17
-     */
18
-    protected $patchService;
19
-
20
-    public function __construct(PatchService $patchService)
21
-    {
22
-        $this->patchService = $patchService;
23
-        parent::__construct();
24
-    }
25
-
26
-    protected function registerOptions(): void
27
-    {
28
-        foreach ($this->patchService->getTypes() as $type) {
29
-            if ($type->getName() !== '') {
30
-                $this->addOption($type->getName(), null, InputOption::VALUE_NONE, 'Applies patches of type "'.$type->getName().'". '.$type->getDescription());
31
-            }
32
-        }
33
-    }
34
-
35
-    protected function applyAll(InputInterface $input, OutputInterface $output)
36
-    {
37
-        $types = [];
38
-        foreach ($this->patchService->getTypes() as $type) {
39
-            if ($type->getName() !== '' && $input->getOption($type->getName())) {
40
-                $types[] = $type->getName();
41
-            }
42
-        }
43
-
44
-        try {
45
-
46
-            [
47
-                'applied' => $appliedPatchArray,
48
-                'skipped' => $skippedPatchArray
49
-            ] = $this->patchService->applyAll($types);
50
-
51
-        } catch (\Exception $e) {
52
-            $output->writeln(sprintf(
53
-                'An error occurred while applying patch: <error>%s</error>', $e->getMessage()
54
-            ));
55
-            throw $e;
56
-        }
57
-
58
-        $msg = $this->getNotificationMessage($appliedPatchArray, $skippedPatchArray);
59
-        if ($msg) {
60
-            $output->writeln($msg);
61
-        } else {
62
-            $output->writeln('<info>No patches to apply</info>');
63
-        }
64
-    }
65
-
66
-    private function getNotificationMessage(array $appliedPatchArray, array $skippedPatchArray): string
67
-    {
68
-        $nbPatchesApplied = array_sum($appliedPatchArray);
69
-        $nbPatchesSkipped = array_sum($skippedPatchArray);
70
-        $msg = '';
71
-        if ($nbPatchesApplied !== 0) {
72
-            $patchArr = [];
73
-            foreach ($appliedPatchArray as $name => $number) {
74
-                $name = $name ?: 'default';
75
-                $patchArr[] = $name.': <info>'.$number.'</info>';
76
-            }
77
-
78
-            $msg .= sprintf('<info>%d</info> patch%s applied (%s)', $nbPatchesApplied, ($nbPatchesApplied > 1)?'es':'', implode(', ', $patchArr))."\n";
79
-        }
80
-        if ($nbPatchesSkipped !== 0) {
81
-            $patchArr = [];
82
-            foreach ($skippedPatchArray as $name => $number) {
83
-                $name = $name ?: 'default';
84
-                $patchArr[] = $name.': <info>'.$number.'</info>';
85
-            }
86
-
87
-            $msg .= sprintf('<info>%d</info><comment> patch%s skipped</comment> (%s)', $nbPatchesSkipped, ($nbPatchesSkipped > 1)?'es':'', implode(', ', $patchArr));
88
-        }
89
-
90
-        return $msg;
91
-    }
15
+	/**
16
+	 * @var PatchService
17
+	 */
18
+	protected $patchService;
19
+
20
+	public function __construct(PatchService $patchService)
21
+	{
22
+		$this->patchService = $patchService;
23
+		parent::__construct();
24
+	}
25
+
26
+	protected function registerOptions(): void
27
+	{
28
+		foreach ($this->patchService->getTypes() as $type) {
29
+			if ($type->getName() !== '') {
30
+				$this->addOption($type->getName(), null, InputOption::VALUE_NONE, 'Applies patches of type "'.$type->getName().'". '.$type->getDescription());
31
+			}
32
+		}
33
+	}
34
+
35
+	protected function applyAll(InputInterface $input, OutputInterface $output)
36
+	{
37
+		$types = [];
38
+		foreach ($this->patchService->getTypes() as $type) {
39
+			if ($type->getName() !== '' && $input->getOption($type->getName())) {
40
+				$types[] = $type->getName();
41
+			}
42
+		}
43
+
44
+		try {
45
+
46
+			[
47
+				'applied' => $appliedPatchArray,
48
+				'skipped' => $skippedPatchArray
49
+			] = $this->patchService->applyAll($types);
50
+
51
+		} catch (\Exception $e) {
52
+			$output->writeln(sprintf(
53
+				'An error occurred while applying patch: <error>%s</error>', $e->getMessage()
54
+			));
55
+			throw $e;
56
+		}
57
+
58
+		$msg = $this->getNotificationMessage($appliedPatchArray, $skippedPatchArray);
59
+		if ($msg) {
60
+			$output->writeln($msg);
61
+		} else {
62
+			$output->writeln('<info>No patches to apply</info>');
63
+		}
64
+	}
65
+
66
+	private function getNotificationMessage(array $appliedPatchArray, array $skippedPatchArray): string
67
+	{
68
+		$nbPatchesApplied = array_sum($appliedPatchArray);
69
+		$nbPatchesSkipped = array_sum($skippedPatchArray);
70
+		$msg = '';
71
+		if ($nbPatchesApplied !== 0) {
72
+			$patchArr = [];
73
+			foreach ($appliedPatchArray as $name => $number) {
74
+				$name = $name ?: 'default';
75
+				$patchArr[] = $name.': <info>'.$number.'</info>';
76
+			}
77
+
78
+			$msg .= sprintf('<info>%d</info> patch%s applied (%s)', $nbPatchesApplied, ($nbPatchesApplied > 1)?'es':'', implode(', ', $patchArr))."\n";
79
+		}
80
+		if ($nbPatchesSkipped !== 0) {
81
+			$patchArr = [];
82
+			foreach ($skippedPatchArray as $name => $number) {
83
+				$name = $name ?: 'default';
84
+				$patchArr[] = $name.': <info>'.$number.'</info>';
85
+			}
86
+
87
+			$msg .= sprintf('<info>%d</info><comment> patch%s skipped</comment> (%s)', $nbPatchesSkipped, ($nbPatchesSkipped > 1)?'es':'', implode(', ', $patchArr));
88
+		}
89
+
90
+		return $msg;
91
+	}
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                 $patchArr[] = $name.': <info>'.$number.'</info>';
76 76
             }
77 77
 
78
-            $msg .= sprintf('<info>%d</info> patch%s applied (%s)', $nbPatchesApplied, ($nbPatchesApplied > 1)?'es':'', implode(', ', $patchArr))."\n";
78
+            $msg .= sprintf('<info>%d</info> patch%s applied (%s)', $nbPatchesApplied, ($nbPatchesApplied > 1) ? 'es' : '', implode(', ', $patchArr))."\n";
79 79
         }
80 80
         if ($nbPatchesSkipped !== 0) {
81 81
             $patchArr = [];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $patchArr[] = $name.': <info>'.$number.'</info>';
85 85
             }
86 86
 
87
-            $msg .= sprintf('<info>%d</info><comment> patch%s skipped</comment> (%s)', $nbPatchesSkipped, ($nbPatchesSkipped > 1)?'es':'', implode(', ', $patchArr));
87
+            $msg .= sprintf('<info>%d</info><comment> patch%s skipped</comment> (%s)', $nbPatchesSkipped, ($nbPatchesSkipped > 1) ? 'es' : '', implode(', ', $patchArr));
88 88
         }
89 89
 
90 90
         return $msg;
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Dumper/DumpableInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
  */
9 9
 interface DumpableInterface
10 10
 {
11
-    public function setDumper(DumperInterface $dumper);
11
+	public function setDumper(DumperInterface $dumper);
12 12
 }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Dumper/Dumper.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
 
9 9
 class Dumper implements DumperInterface
10 10
 {
11
-    /**
12
-     * @var OutputInterface
13
-     */
14
-    private $output;
11
+	/**
12
+	 * @var OutputInterface
13
+	 */
14
+	private $output;
15 15
 
16
-    public function __construct(OutputInterface $output)
17
-    {
18
-        $this->output = $output;
19
-    }
16
+	public function __construct(OutputInterface $output)
17
+	{
18
+		$this->output = $output;
19
+	}
20 20
 
21
-    public function dumpPatch(string $code): void
22
-    {
23
-        $this->output->writeln($code);
24
-    }
21
+	public function dumpPatch(string $code): void
22
+	{
23
+		$this->output->writeln($code);
24
+	}
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Dumper/DumperInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 
7 7
 interface DumperInterface
8 8
 {
9
-    public function dumpPatch(string $code): void;
9
+	public function dumpPatch(string $code): void;
10 10
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/RevertPatchCommand.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 class RevertPatchCommand extends Command
18 18
 {
19
-    /**
20
-     * @var PatchService
21
-     */
22
-    private $patchService;
19
+	/**
20
+	 * @var PatchService
21
+	 */
22
+	private $patchService;
23 23
 
24
-    public function __construct(PatchService $patchService)
25
-    {
26
-        parent::__construct();
27
-        $this->patchService = $patchService;
28
-    }
24
+	public function __construct(PatchService $patchService)
25
+	{
26
+		parent::__construct();
27
+		$this->patchService = $patchService;
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * {@inheritdoc}
33
-     */
34
-    protected function configure()
35
-    {
36
-        $this
37
-        ->setName('patches:revert')
38
-        ->setDescription('Revert a patch.')
39
-        ->addArgument(
40
-            'name',
41
-            InputArgument::REQUIRED,
42
-            'The name of the patch instance to be reverted'
43
-        )
44
-        ->setHelp(<<<EOT
31
+	/**
32
+	 * {@inheritdoc}
33
+	 */
34
+	protected function configure()
35
+	{
36
+		$this
37
+		->setName('patches:revert')
38
+		->setDescription('Revert a patch.')
39
+		->addArgument(
40
+			'name',
41
+			InputArgument::REQUIRED,
42
+			'The name of the patch instance to be reverted'
43
+		)
44
+		->setHelp(<<<EOT
45 45
 Reverts a patch. You must pass in parameter the name of the patch.
46 46
 EOT
47
-        );
47
+		);
48 48
 
49
-        $this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The patch will still be reverted.');
50
-    }
49
+		$this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The patch will still be reverted.');
50
+	}
51 51
 
52
-    /**
53
-     * {@inheritdoc}
54
-     */
55
-    protected function execute(InputInterface $input, OutputInterface $output)
56
-    {
57
-        if ($input->getOption('dump')) {
58
-            $this->patchService->setDumper(new Dumper($output));
59
-        }
52
+	/**
53
+	 * {@inheritdoc}
54
+	 */
55
+	protected function execute(InputInterface $input, OutputInterface $output)
56
+	{
57
+		if ($input->getOption('dump')) {
58
+			$this->patchService->setDumper(new Dumper($output));
59
+		}
60 60
 
61
-        $patchName = $input->getArgument('name');
62
-        $this->patchService->revert($patchName);
61
+		$patchName = $input->getArgument('name');
62
+		$this->patchService->revert($patchName);
63 63
 
64
-        $output->writeln('Patch successfully reverted');
65
-    }
64
+		$output->writeln('Patch successfully reverted');
65
+	}
66 66
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ApplyPatchCommand.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,54 +16,54 @@
 block discarded – undo
16 16
  */
17 17
 class ApplyPatchCommand extends Command
18 18
 {
19
-    /**
20
-     * @var PatchService
21
-     */
22
-    private $patchService;
19
+	/**
20
+	 * @var PatchService
21
+	 */
22
+	private $patchService;
23 23
 
24
-    public function __construct(PatchService $patchService)
25
-    {
26
-        parent::__construct();
27
-        $this->patchService = $patchService;
28
-    }
24
+	public function __construct(PatchService $patchService)
25
+	{
26
+		parent::__construct();
27
+		$this->patchService = $patchService;
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * {@inheritdoc}
33
-     */
34
-    protected function configure()
35
-    {
36
-        $this
37
-        ->setName('patches:apply')
38
-        ->setDescription('Apply a patch.')
39
-        ->addArgument(
40
-            'name',
41
-            InputArgument::REQUIRED,
42
-            'The name of the patch instance to be applied'
43
-        )
44
-        ->setHelp(<<<EOT
31
+	/**
32
+	 * {@inheritdoc}
33
+	 */
34
+	protected function configure()
35
+	{
36
+		$this
37
+		->setName('patches:apply')
38
+		->setDescription('Apply a patch.')
39
+		->addArgument(
40
+			'name',
41
+			InputArgument::REQUIRED,
42
+			'The name of the patch instance to be applied'
43
+		)
44
+		->setHelp(<<<EOT
45 45
 Apply a patch. You must pass in parameter the name of the patch.
46 46
 
47 47
 Use patches:apply-all to apply all pending patches.
48 48
 EOT
49
-        );
49
+		);
50 50
 
51
-        $this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The patch will still be applied.');
52
-    }
51
+		$this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The patch will still be applied.');
52
+	}
53 53
 
54
-    /**
55
-     * {@inheritdoc}
56
-     */
57
-    protected function execute(InputInterface $input, OutputInterface $output)
58
-    {
59
-        if ($input->getOption('dump')) {
60
-            $this->patchService->setDumper(new Dumper($output));
61
-        }
54
+	/**
55
+	 * {@inheritdoc}
56
+	 */
57
+	protected function execute(InputInterface $input, OutputInterface $output)
58
+	{
59
+		if ($input->getOption('dump')) {
60
+			$this->patchService->setDumper(new Dumper($output));
61
+		}
62 62
 
63 63
 
64
-        $patchName = $input->getArgument('name');
65
-        $this->patchService->apply($patchName);
64
+		$patchName = $input->getArgument('name');
65
+		$this->patchService->apply($patchName);
66 66
 
67
-        $output->writeln('Patch successfully applied');
68
-    }
67
+		$output->writeln('Patch successfully applied');
68
+	}
69 69
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ResetPatchesCommand.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
  */
17 17
 class ResetPatchesCommand extends AbstractApplyAllCommand
18 18
 {
19
-    /**
20
-     * {@inheritdoc}
21
-     */
22
-    protected function configure()
23
-    {
24
-        $this
25
-        ->setName('patches:reset')
26
-        ->setDescription('Reset database and reapply all patches.')
27
-        ->setDefinition(array(
28
-
29
-        ))
30
-        ->setHelp(<<<EOT
19
+	/**
20
+	 * {@inheritdoc}
21
+	 */
22
+	protected function configure()
23
+	{
24
+		$this
25
+		->setName('patches:reset')
26
+		->setDescription('Reset database and reapply all patches.')
27
+		->setDefinition(array(
28
+
29
+		))
30
+		->setHelp(<<<EOT
31 31
 Reset the database and reapplies all pending patches. You can select the type of patches to be applied using the options. Default patches are always applied.
32 32
 
33 33
 Use patches:apply-all if you want to apply remaining patches without resetting the database.
34 34
 EOT
35
-        );
35
+		);
36 36
 
37
-        $this->registerOptions();
37
+		$this->registerOptions();
38 38
 
39
-        $this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The database will still be reset.');
40
-    }
39
+		$this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patch to the output. Note: this is not a "dry" mode. The database will still be reset.');
40
+	}
41 41
 
42
-    /**
43
-     * {@inheritdoc}
44
-     */
45
-    protected function execute(InputInterface $input, OutputInterface $output)
46
-    {
47
-        if ($input->getOption('dump')) {
48
-            $this->patchService->setDumper(new Dumper($output));
49
-        }
42
+	/**
43
+	 * {@inheritdoc}
44
+	 */
45
+	protected function execute(InputInterface $input, OutputInterface $output)
46
+	{
47
+		if ($input->getOption('dump')) {
48
+			$this->patchService->setDumper(new Dumper($output));
49
+		}
50 50
 
51
-        $this->patchService->reset();
51
+		$this->patchService->reset();
52 52
 
53
-        $this->applyAll($input, $output);
54
-    }
53
+		$this->applyAll($input, $output);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ApplyAllPatchesCommand.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -18,37 +18,37 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * {@inheritdoc}
23
-     */
24
-    protected function configure()
25
-    {
26
-        $this
27
-        ->setName('patches:apply-all')
28
-        ->setDescription('Apply pending patches.')
29
-        ->setDefinition(array(
30
-
31
-        ))
32
-        ->setHelp(<<<EOT
21
+	/**
22
+	 * {@inheritdoc}
23
+	 */
24
+	protected function configure()
25
+	{
26
+		$this
27
+		->setName('patches:apply-all')
28
+		->setDescription('Apply pending patches.')
29
+		->setDefinition(array(
30
+
31
+		))
32
+		->setHelp(<<<EOT
33 33
 Apply pending patches. You can select the type of patches to be applied using the options. Default patches are always applied.
34 34
 
35 35
 Use patches:apply if you want to cherry-pick a particular patch.
36 36
 EOT
37
-        );
38
-
39
-        $this->registerOptions();
40
-
41
-        $this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patches to the output. Note: this is not a "dry" mode. The patches will still be applied.');
42
-    }
43
-
44
-    /**
45
-     * {@inheritdoc}
46
-     */
47
-    protected function execute(InputInterface $input, OutputInterface $output)
48
-    {
49
-        if ($input->getOption('dump')) {
50
-            $this->patchService->setDumper(new Dumper($output));
51
-        }
52
-        $this->applyAll($input, $output);
53
-    }
37
+		);
38
+
39
+		$this->registerOptions();
40
+
41
+		$this->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps the patches to the output. Note: this is not a "dry" mode. The patches will still be applied.');
42
+	}
43
+
44
+	/**
45
+	 * {@inheritdoc}
46
+	 */
47
+	protected function execute(InputInterface $input, OutputInterface $output)
48
+	{
49
+		if ($input->getOption('dump')) {
50
+			$this->patchService->setDumper(new Dumper($output));
51
+		}
52
+		$this->applyAll($input, $output);
53
+	}
54 54
 }
Please login to merge, or discard this patch.