|
16 | 16 |
|
17 | 17 | final class TestFlagCommand extends Command
|
18 | 18 | {
|
19 |
| - public function __construct( |
20 |
| - string $name, |
21 |
| - private readonly Unleash $unleash, |
22 |
| - private readonly CacheInterface $cache, |
23 |
| - ) { |
| 19 | + /** |
| 20 | + * @readonly |
| 21 | + */ |
| 22 | + private Unleash $unleash; |
| 23 | + /** |
| 24 | + * @readonly |
| 25 | + */ |
| 26 | + private CacheInterface $cache; |
| 27 | + public function __construct(string $name, Unleash $unleash, CacheInterface $cache) |
| 28 | + { |
| 29 | + $this->unleash = $unleash; |
| 30 | + $this->cache = $cache; |
24 | 31 | parent::__construct($name);
|
25 | 32 | }
|
26 |
| - |
27 | 33 | protected function configure(): void
|
28 | 34 | {
|
29 | 35 | $this
|
30 | 36 | ->setDescription('Check the status of an Unleash feature')
|
31 | 37 | ->addArgument(
|
32 |
| - name: 'flag', |
33 |
| - mode: InputArgument::REQUIRED, |
34 |
| - description: 'The name of the feature flag to check the result for', |
| 38 | + 'flag', |
| 39 | + InputArgument::REQUIRED, |
| 40 | + 'The name of the feature flag to check the result for', |
35 | 41 | )
|
36 | 42 | ->addOption(
|
37 |
| - name: 'force', |
38 |
| - shortcut: 'f', |
39 |
| - mode: InputOption::VALUE_NONE, |
40 |
| - description: 'When this flag is present, fresh results without cache will be forced', |
| 43 | + 'force', |
| 44 | + 'f', |
| 45 | + InputOption::VALUE_NONE, |
| 46 | + 'When this flag is present, fresh results without cache will be forced', |
41 | 47 | )
|
42 | 48 | ->addOption(
|
43 |
| - name: 'user-id', |
44 |
| - mode: InputOption::VALUE_REQUIRED, |
45 |
| - description: "[Context] Provide the current user's ID", |
46 |
| - default: null, |
| 49 | + 'user-id', |
| 50 | + null, |
| 51 | + InputOption::VALUE_REQUIRED, |
| 52 | + "[Context] Provide the current user's ID", |
| 53 | + null, |
47 | 54 | )
|
48 | 55 | ->addOption(
|
49 |
| - name: 'ip-address', |
50 |
| - mode: InputOption::VALUE_REQUIRED, |
51 |
| - description: '[Context] Provide the current IP address', |
52 |
| - default: null, |
| 56 | + 'ip-address', |
| 57 | + null, |
| 58 | + InputOption::VALUE_REQUIRED, |
| 59 | + '[Context] Provide the current IP address', |
| 60 | + null, |
53 | 61 | )
|
54 | 62 | ->addOption(
|
55 |
| - name: 'session-id', |
56 |
| - mode: InputOption::VALUE_REQUIRED, |
57 |
| - description: '[Context] Provide the current session ID', |
58 |
| - default: null, |
| 63 | + 'session-id', |
| 64 | + null, |
| 65 | + InputOption::VALUE_REQUIRED, |
| 66 | + '[Context] Provide the current session ID', |
| 67 | + null, |
59 | 68 | )
|
60 | 69 | ->addOption(
|
61 |
| - name: 'hostname', |
62 |
| - mode: InputOption::VALUE_REQUIRED, |
63 |
| - description: '[Context] Provide the current hostname', |
64 |
| - default: null, |
| 70 | + 'hostname', |
| 71 | + null, |
| 72 | + InputOption::VALUE_REQUIRED, |
| 73 | + '[Context] Provide the current hostname', |
| 74 | + null, |
65 | 75 | )
|
66 | 76 | ->addOption(
|
67 |
| - name: 'environment', |
68 |
| - mode: InputOption::VALUE_REQUIRED, |
69 |
| - description: '[Context] Provide the current environment', |
70 |
| - default: null, |
| 77 | + 'environment', |
| 78 | + null, |
| 79 | + InputOption::VALUE_REQUIRED, |
| 80 | + '[Context] Provide the current environment', |
| 81 | + null, |
71 | 82 | )
|
72 | 83 | ->addOption(
|
73 |
| - name: 'current-time', |
74 |
| - mode: InputOption::VALUE_REQUIRED, |
75 |
| - description: '[Context] Provide the current date and time', |
76 |
| - default: null, |
| 84 | + 'current-time', |
| 85 | + null, |
| 86 | + InputOption::VALUE_REQUIRED, |
| 87 | + '[Context] Provide the current date and time', |
| 88 | + null, |
77 | 89 | )
|
78 | 90 | ->addOption(
|
79 | 91 | 'custom-context',
|
80 |
| - mode: InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
81 |
| - description: '[Context] Custom context values in the format [contextName]=[contextValue], for example: myCustomContextField=someValue', |
82 |
| - default: null, |
| 92 | + null, |
| 93 | + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
| 94 | + '[Context] Custom context values in the format [contextName]=[contextValue], for example: myCustomContextField=someValue', |
| 95 | + null, |
83 | 96 | )
|
84 | 97 | ->addOption( // must use positional arguments, because $suggestedValues is not a real argument
|
85 | 98 | 'expected',
|
@@ -159,13 +172,13 @@ private function createContext(InputInterface $input): Context
|
159 | 172 | assert($currentTime === null || is_string($currentTime));
|
160 | 173 |
|
161 | 174 | return new UnleashContext(
|
162 |
| - currentUserId: $userId, |
163 |
| - ipAddress: $ipAddress, |
164 |
| - sessionId: $sessionId, |
165 |
| - customContext: $customContext, |
166 |
| - hostname: $hostname, |
167 |
| - environment: $environment, |
168 |
| - currentTime: $currentTime, |
| 175 | + $userId, |
| 176 | + $ipAddress, |
| 177 | + $sessionId, |
| 178 | + $customContext, |
| 179 | + $hostname, |
| 180 | + $environment, |
| 181 | + $currentTime, |
169 | 182 | );
|
170 | 183 | }
|
171 | 184 | }
|
0 commit comments