These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Elastica\Bulk\Action; |
||
4 | |||
5 | use Elastica\AbstractUpdateAction; |
||
6 | use Elastica\Document; |
||
7 | |||
8 | class IndexDocument extends AbstractDocument |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $_opType = self::OP_TYPE_INDEX; |
||
14 | |||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | public function setDocument(Document $document): AbstractDocument |
||
19 | { |
||
20 | parent::setDocument($document); |
||
21 | |||
22 | $this->setSource($document->getData()); |
||
23 | |||
24 | return $this; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | View Code Duplication | protected function _getMetadata(AbstractUpdateAction $action): array |
|
0 ignored issues
–
show
|
|||
31 | { |
||
32 | return $action->getOptions([ |
||
33 | '_index', |
||
34 | '_id', |
||
35 | 'version', |
||
36 | 'version_type', |
||
37 | 'routing', |
||
38 | 'parent', |
||
39 | 'retry_on_conflict', |
||
40 | ]); |
||
41 | } |
||
42 | } |
||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.