| Total Complexity | 4 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class DocumentCleaner implements DocumentCleanerInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var \Elastica\Client |
||
| 15 | */ |
||
| 16 | private $client; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * DocumentBuilder constructor. |
||
| 20 | * |
||
| 21 | * @param \Elastica\Client $client |
||
| 22 | */ |
||
| 23 | 1 | public function __construct(Client $client) |
|
| 24 | { |
||
| 25 | 1 | $this->client = $client; |
|
| 26 | 1 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @param \DataProvider\DocumentListDataProvider $listDataProvider |
||
| 30 | */ |
||
| 31 | 1 | public function deleteDocuments(DocumentListDataProvider $listDataProvider): void |
|
| 32 | { |
||
| 33 | 1 | $documents = $this->getDocumentsFromDataProvider($listDataProvider); |
|
| 34 | |||
| 35 | $type = $this |
||
| 36 | 1 | ->client |
|
| 37 | 1 | ->getIndex($listDataProvider->getIndex()) |
|
| 38 | 1 | ->getType($listDataProvider->getType()); |
|
| 39 | |||
| 40 | 1 | $type->deleteDocuments($documents); |
|
| 41 | |||
| 42 | 1 | $type->getIndex()->refresh(); |
|
| 43 | 1 | } |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @param \DataProvider\DocumentListDataProvider $listDataProvider |
||
| 47 | * @param array $document |
||
| 48 | * |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | 1 | protected function getDocumentsFromDataProvider(DocumentListDataProvider $listDataProvider): array |
|
| 63 | } |
||
| 64 | } |