| Total Complexity | 2 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 57.14% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait ShardPicker |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var null|string |
||
| 16 | */ |
||
| 17 | private $shardId; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Pick up a shard manually from the distribution value |
||
| 21 | * This query will be executed only on the targeted shard |
||
| 22 | * |
||
| 23 | * @param mixed $distributionValue |
||
| 24 | * |
||
| 25 | * @return $this |
||
| 26 | */ |
||
| 27 | 6 | public function pickShard($distributionValue) |
|
| 28 | { |
||
| 29 | 6 | $this->shardId = $this->connection->getShardChoser() |
|
| 30 | 6 | ->pick($distributionValue, $this->connection); |
|
| 31 | |||
| 32 | 6 | return $this; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Set the shard manually |
||
| 37 | * This query will be executed only on this shard |
||
| 38 | * |
||
| 39 | * @param null|string $shardId |
||
| 40 | * |
||
| 41 | * @return $this |
||
| 42 | */ |
||
| 43 | public function useShard(?string $shardId) |
||
| 48 | } |
||
| 49 | } |