| Conditions | 7 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public function getChoice(string $decisionId): ?string |
||
| 30 | { |
||
| 31 | if (!isset($this->choices)) { |
||
| 32 | $cache = $this->redis->get(CacheGenerator::REDIS_KEY); |
||
| 33 | |||
| 34 | if (is_null($cache)) { // @phpstan-ignore-line |
||
| 35 | $this->choices = []; |
||
| 36 | |||
| 37 | return null; |
||
| 38 | } |
||
| 39 | |||
| 40 | $choicesArray = json_decode($cache, true); |
||
| 41 | |||
| 42 | if (is_null($choicesArray)) { |
||
| 43 | $this->choices = []; |
||
| 44 | |||
| 45 | return null; |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->choices = $choicesArray; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (!isset($this->choices[$decisionId])) { |
||
| 52 | return null; |
||
| 53 | } |
||
| 54 | |||
| 55 | if ('control' !== $this->choices[$decisionId] && 'experiment' !== $this->choices[$decisionId]) { |
||
| 56 | return null; |
||
| 57 | } |
||
| 58 | |||
| 59 | return $this->choices[$decisionId]; |
||
| 60 | } |
||
| 62 |