AbstractCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Aoe\FeatureFlag\Command;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2024 AOE GmbH <[email protected]>
9
 *
10
 *  All rights reserved
11
 *
12
 *  This script is part of the TYPO3 project. The TYPO3 project is
13
 *  free software; you can redistribute it and/or modify
14
 *  it under the terms of the GNU General Public License as published by
15
 *  the Free Software Foundation; either version 3 of the License, or
16
 *  (at your option) any later version.
17
 *
18
 *  The GNU General Public License can be found at
19
 *  http://www.gnu.org/copyleft/gpl.html.
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28
29
use Aoe\FeatureFlag\Service\FeatureFlagService;
30
use Symfony\Component\Console\Command\Command;
31
use Symfony\Component\Console\Style\SymfonyStyle;
32
33
abstract class AbstractCommand extends Command
34
{
35
    protected SymfonyStyle $inputOutput;
36
37
    public function __construct(
38
        protected FeatureFlagService $featureFlagService
39
    ) {
40
        parent::__construct();
41 3
    }
42
43 3
    /**
44 3
     * Enable or disable features. $features can be a comma-separated list of feature names
45 3
     */
46
    protected function setFeatureStatus(string $features, bool $enabled): void
47
    {
48
        $features = array_map(trim(...), explode(',', $features));
0 ignored issues
show
Bug introduced by
The type Aoe\FeatureFlag\Command\trim was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
49
        foreach ($features as $feature) {
50
            $info = ($enabled) ? 'Activate' : 'Deactivate';
51
            $this->showInfo($info . ' feature: ' . $feature);
52 2
            $this->featureFlagService->updateFeatureFlag($feature, $enabled);
53
        }
54 2
55 2
        $this->showInfo('Update visibility of records (e.g. content elements), which are connected with features');
56 2
        $this->featureFlagService->flagEntries();
57 2
    }
58 2
59
    protected function showInfo(string $info): void
60 2
    {
61 2
        $this->inputOutput->block($info, 'INFO', 'fg=green', '', false);
62 2
    }
63
}
64