| Total Complexity | 4 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class MappingClient implements MappingClientInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var Client |
||
| 18 | */ |
||
| 19 | private $client; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param Client $client |
||
| 23 | */ |
||
| 24 | public function __construct(Client $client) |
||
| 25 | { |
||
| 26 | $this->client = $client; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function apply(string $index, string $type, MappingInterface $mapping): void |
||
| 30 | { |
||
| 31 | $serialized = Mapping::asObject($mapping); |
||
| 32 | unset($serialized->type); |
||
| 33 | $parameters = [ |
||
| 34 | 'index' => $index, |
||
| 35 | 'type' => $type, |
||
| 36 | 'body' => [$type => $serialized] |
||
| 37 | ]; |
||
| 38 | $this |
||
| 39 | ->client |
||
| 40 | ->indices() |
||
| 41 | ->putMapping($parameters); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function get(string $index, string $type): ?MappingInterface |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 |