Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
70.00% |
7 / 10 |
|
70.00% |
7 / 10 |
CRAP | |
0.00% |
0 / 1 |
| ConstantAssignment | |
70.00% |
7 / 10 |
|
70.00% |
7 / 10 |
12.70 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| uniqueId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getServerList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSearchCluster | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getManagedClusters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getWritableClusters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasCluster | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canManageCluster | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canWriteToCluster | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCrossClusterName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Assignment; |
| 4 | |
| 5 | class ConstantAssignment implements ClusterAssignment { |
| 6 | /** @var string[]|array[] Elastica connection configuration */ |
| 7 | private $servers; |
| 8 | |
| 9 | /** |
| 10 | * @param string[]|array[] $servers Elastica connection configuration |
| 11 | */ |
| 12 | public function __construct( array $servers ) { |
| 13 | $this->servers = $servers; |
| 14 | } |
| 15 | |
| 16 | /** @inheritDoc */ |
| 17 | public function uniqueId( $cluster ) { |
| 18 | return 'default'; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @param string|null $cluster |
| 23 | * @return string[]|array[] |
| 24 | */ |
| 25 | public function getServerList( $cluster = null ): array { |
| 26 | return $this->servers; |
| 27 | } |
| 28 | |
| 29 | /** @inheritDoc */ |
| 30 | public function getSearchCluster() { |
| 31 | return 'default'; |
| 32 | } |
| 33 | |
| 34 | public function getManagedClusters(): array { |
| 35 | return [ 'default' ]; |
| 36 | } |
| 37 | |
| 38 | /** @inheritDoc */ |
| 39 | public function getWritableClusters( string $updateGroup ): array { |
| 40 | return [ 'default' ]; |
| 41 | } |
| 42 | |
| 43 | /** @inheritDoc */ |
| 44 | public function hasCluster( string $clusterName ): bool { |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @param string $clusterName |
| 50 | * @return bool True when the named cluster is in the set of managable clusters. |
| 51 | */ |
| 52 | public function canManageCluster( $clusterName ): bool { |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public function canWriteToCluster( $clusterName, $updateGroup ) { |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | /** @inheritDoc */ |
| 62 | public function getCrossClusterName() { |
| 63 | return null; |
| 64 | } |
| 65 | } |