Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| ReindexResponse | |
0.00% |
0 / 11 |
|
0.00% |
0 / 7 |
132 | |
0.00% |
0 / 1 |
| isSuccessful | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| getUnsuccessfulReason | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| isComplete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isFailed | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getFailures | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isCanceled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| getCanceledReason | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Elastica; |
| 4 | |
| 5 | use LogicException; |
| 6 | |
| 7 | class ReindexResponse extends ReindexStatus { |
| 8 | /** |
| 9 | * @return bool True when the reindex completed successfully |
| 10 | */ |
| 11 | public function isSuccessful() { |
| 12 | return !$this->isFailed() && !$this->isCanceled(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * @return string The reason the reindex was unsuccessful |
| 17 | */ |
| 18 | public function getUnsuccessfulReason() { |
| 19 | if ( $this->isCanceled() ) { |
| 20 | return "Canceled: " . $this->getCanceledReason(); |
| 21 | } elseif ( $this->isFailed() ) { |
| 22 | return "Failed: " . json_encode( $this->getFailures() ); |
| 23 | } else { |
| 24 | throw new LogicException( "Request was successful" ); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @return bool |
| 30 | */ |
| 31 | public function isComplete() { |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @return bool |
| 37 | */ |
| 38 | public function isFailed() { |
| 39 | return !empty( $this->status['failures'] ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @return string[] |
| 44 | */ |
| 45 | public function getFailures() { |
| 46 | return $this->status['failures']; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @return bool True If the reindex was canceled (as opposed to failing) |
| 51 | */ |
| 52 | public function isCanceled() { |
| 53 | return isset( $this->status['canceled'] ) && (bool)$this->status['canceled']; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @return string The reason the reindex was canceled |
| 58 | */ |
| 59 | public function getCanceledReason() { |
| 60 | return $this->status['canceled']; |
| 61 | } |
| 62 | } |