| Total Complexity | 2 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Helpers |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The loop used to create the Fulfilled Promise. |
||
| 11 | * |
||
| 12 | * @var null|\React\EventLoop\LoopInterface |
||
| 13 | */ |
||
| 14 | public static $loop = null; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Transform the Redis' list of key after value |
||
| 18 | * to key-value pairs. |
||
| 19 | * |
||
| 20 | * @param array $list |
||
| 21 | * @return array |
||
| 22 | */ |
||
| 23 | public static function redisListToArray(array $list) |
||
| 24 | { |
||
| 25 | // Redis lists come into a format where the keys are on even indexes |
||
| 26 | // and the values are on odd indexes. This way, we know which |
||
| 27 | // ones are keys and which ones are values and their get combined |
||
| 28 | // later to form the key => value array. |
||
| 29 | [$keys, $values] = collect($list)->partition(function ($value, $key) { |
||
| 30 | return $key % 2 === 0; |
||
| 31 | }); |
||
| 32 | |||
| 33 | return array_combine($keys->all(), $values->all()); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Create a new fulfilled promise with a value. |
||
| 38 | * |
||
| 39 | * @param mixed $value |
||
| 40 | * @return \React\Promise\PromiseInterface |
||
| 41 | */ |
||
| 42 | public static function createFulfilledPromise($value): PromiseInterface |
||
| 49 | } |
||
| 50 | } |
||
| 51 |