Total Complexity | 6 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class BootstrapStrategy |
||
9 | { |
||
10 | /** |
||
11 | * @var \Vaimo\ComposerPatches\Composer\Context |
||
12 | */ |
||
13 | private $composerContext; |
||
14 | |||
15 | /** |
||
16 | * @param \Vaimo\ComposerPatches\Composer\Context $composerContext |
||
17 | */ |
||
18 | public function __construct( |
||
22 | } |
||
23 | |||
24 | public function shouldAllow() |
||
25 | { |
||
26 | if (!$this->isPluginAvailable()) { |
||
27 | return false; |
||
28 | } |
||
29 | |||
30 | $lockUpdateArgument = 'lock'; |
||
31 | |||
32 | try { |
||
33 | $input = new \Symfony\Component\Console\Input\ArgvInput(); |
||
34 | |||
35 | return !$input->hasParameterOption(sprintf('--%s', $lockUpdateArgument)); |
||
36 | } catch (\Exception $e) { |
||
37 | // There are situations where composer is accessed from non-CLI entry-points, |
||
38 | // which will cause $argv not to be available, resulting a crash. |
||
39 | } |
||
40 | |||
41 | return false; |
||
42 | } |
||
43 | |||
44 | private function isPluginAvailable() |
||
61 | } |
||
62 | } |
||
63 |