Passed
Pull Request — master (#17)
by Gordon
03:48
created

BulkIndexDirtyJob::hydrate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 25/3/2561
7
 * Time: 17:01 น.
8
 */
9
10
namespace Suilven\FreeTextSearch\QueuedJob;
11
12
use Suilven\FreeTextSearch\Helper\BulkIndexingHelper;
13
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
14
15
class BulkIndexDirtyJob extends AbstractQueuedJob
16
{
17
18
    // variable $indexName cannot be declared here, because serialization of the job does not store this variable
19
20
    public function getTitle(): string
21
    {
22
        return 'Bulk Index Dirty DataObjects';
23
    }
24
25
26
    /** @param string $newIndexName the name of the index */
27
    public function hydrate(string $newIndexName): void
28
    {
29
        // @phpstan-ignore-next-line
30
        $this->indexName = $newIndexName;
0 ignored issues
show
Bug Best Practice introduced by
The property indexName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
    }
32
33
34
    public function setup(): void
35
    {
36
        $this->totalSteps = 1;
37
    }
38
39
40
    public function process(): void
41
    {
42
        $helper = new BulkIndexingHelper();
43
44
        // @phpstan-ignore-next-line
45
        $helper->bulkIndex($this->indexName, true);
46
47
        $this->isComplete = true;
48
    }
49
}
50