| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | final class DocumentMetadata |
||
| 26 | { |
||
| 27 | const DEFAULT_TYPE = '_doc'; |
||
| 28 | |||
| 29 | private $index; |
||
| 30 | private $type; |
||
| 31 | |||
| 32 | public function __construct(string $index = null, string $type = self::DEFAULT_TYPE) |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Gets a new instance with the given index. |
||
| 40 | */ |
||
| 41 | public function withIndex(string $index): self |
||
| 42 | { |
||
| 43 | $metadata = clone $this; |
||
| 44 | $metadata->index = $index; |
||
| 45 | |||
| 46 | return $metadata; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Gets the document index. |
||
| 51 | */ |
||
| 52 | public function getIndex() |
||
| 53 | { |
||
| 54 | return $this->index; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Gets a new instance with the given type. |
||
| 59 | */ |
||
| 60 | public function withType(string $type): self |
||
| 61 | { |
||
| 62 | $metadata = clone $this; |
||
| 63 | $metadata->type = $type; |
||
| 64 | |||
| 65 | return $metadata; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Gets the document type. |
||
| 70 | */ |
||
| 71 | public function getType(): string |
||
| 74 | } |
||
| 75 | } |
||
| 76 |