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