Skip to content

Commit 846c265

Browse files
committed
formatting
1 parent 1d7a054 commit 846c265

File tree

7 files changed

+35
-92
lines changed

7 files changed

+35
-92
lines changed

src/Commands/IndexCommand.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,18 @@
1414

1515
class IndexCommand extends Command
1616
{
17-
/**
18-
* The name and signature of the console command.
19-
*
20-
* @var string
21-
*/
2217
protected $signature = 'elastica-bridge:index {index?*} {--delete}';
2318

24-
/**
25-
* The console command description.
26-
*
27-
* @var string
28-
*/
2919
protected $description = 'Re-create the ES index and populate with data';
3020

31-
/**
32-
* Create a new command instance.
33-
*
34-
* @return void
35-
*/
36-
public function __construct(protected ElasticaClient $elastica, protected IndexRepository $indexRepository)
37-
{
21+
public function __construct(
22+
protected ElasticaClient $elastica,
23+
protected IndexRepository $indexRepository
24+
) {
3825
parent::__construct();
3926
}
4027

41-
/**
42-
* Execute the console command.
43-
*
44-
* @return int
45-
*/
46-
public function handle()
28+
public function handle(): int
4729
{
4830
foreach ($this->indexRepository->all() as $indexConfig) {
4931
if (
@@ -68,6 +50,6 @@ public function handle()
6850
->dispatch();
6951
}
7052

71-
return 0;
53+
return self::SUCCESS;
7254
}
7355
}

src/Commands/StatusCommand.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,18 @@
1212

1313
class StatusCommand extends Command
1414
{
15-
/**
16-
* The name and signature of the console command.
17-
*
18-
* @var string
19-
*/
2015
protected $signature = 'elastica-bridge:status';
2116

22-
/**
23-
* The console command description.
24-
*
25-
* @var string
26-
*/
2717
protected $description = 'Displays the status of the configured Elasticsearch indices';
2818

29-
/**
30-
* Create a new command instance.
31-
*
32-
* @return void
33-
*/
34-
public function __construct(protected ElasticaClient $elastica, protected IndexRepository $indexRepository)
35-
{
19+
public function __construct(
20+
protected ElasticaClient $elastica,
21+
protected IndexRepository $indexRepository
22+
) {
3623
parent::__construct();
3724
}
3825

39-
/**
40-
* Execute the console command.
41-
*
42-
* @return int
43-
*/
44-
public function handle()
26+
public function handle(): int
4527
{
4628
$table = new Table($this->output);
4729
$table
@@ -100,7 +82,7 @@ public function handle()
10082
->setHeaderTitle('Indices');
10183
$table->render();
10284

103-
return 0;
85+
return self::SUCCESS;
10486
}
10587

10688
protected function formatBoolean(bool $val): string

src/Jobs/ActivateIndex.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@
88

99
class ActivateIndex extends AbstractIndexJob
1010
{
11-
/**
12-
* Create a new job instance.
13-
*
14-
* @return void
15-
*/
1611
public function __construct(protected IndexInterface $indexConfig)
1712
{
18-
//
1913
}
2014

21-
/**
22-
* Execute the job.
23-
*/
2415
public function handle(): void
2516
{
2617
$oldIndex = $this->indexConfig->getBlueGreenActiveElasticaIndex();

src/Jobs/PopulateBatchIndex.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ class PopulateBatchIndex implements ShouldQueue
2222
use Queueable;
2323
use SerializesModels;
2424

25-
/**
26-
* Create a new job instance.
27-
*
28-
* @return void
29-
*/
30-
public function __construct(protected Index $index, protected IndexInterface $indexConfig, protected string $indexDocument, protected int $limit, protected int $offset)
31-
{
32-
//
25+
public function __construct(
26+
protected Index $index,
27+
protected IndexInterface $indexConfig,
28+
protected string $indexDocument,
29+
protected int $limit,
30+
protected int $offset
31+
) {
3332
}
3433

35-
/**
36-
* Execute the job.
37-
*/
3834
public function handle(): void
3935
{
4036
if ($this->batch()?->cancelled()) {

src/Jobs/PopulateIndex.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,10 @@ class PopulateIndex extends AbstractIndexJob
1111
{
1212
use Batchable;
1313

14-
/**
15-
* Create a new job instance.
16-
*
17-
* @return void
18-
*/
1914
public function __construct(protected IndexInterface $indexConfig)
2015
{
21-
//
2216
}
2317

24-
/**
25-
* Execute the job.
26-
*/
2718
public function handle(): void
2819
{
2920
if ($this->batch()?->cancelled()) {
@@ -41,7 +32,13 @@ public function handle(): void
4132
$modelCount = $indexDocument::count();
4233

4334
for ($batchNumber = 0; $batchNumber < ceil($modelCount / $this->indexConfig->getBatchSize()); $batchNumber++) {
44-
$jobs[] = new PopulateBatchIndex($index, $this->indexConfig, $indexDocument, $this->indexConfig->getBatchSize(), $batchNumber * $this->indexConfig->getBatchSize());
35+
$jobs[] = new PopulateBatchIndex(
36+
$index,
37+
$this->indexConfig,
38+
$indexDocument,
39+
$this->indexConfig->getBatchSize(),
40+
$batchNumber * $this->indexConfig->getBatchSize()
41+
);
4542
}
4643
}
4744

src/Jobs/SetupIndex.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@ class SetupIndex extends AbstractIndexJob
1313
{
1414
use Batchable;
1515

16-
/**
17-
* Create a new job instance.
18-
*
19-
* @return void
20-
*/
21-
public function __construct(protected IndexInterface $indexConfig, protected bool $deleteExisting)
22-
{
23-
//
16+
public function __construct(
17+
protected IndexInterface $indexConfig,
18+
protected bool $deleteExisting
19+
) {
2420
}
2521

26-
/**
27-
* Execute the job.
28-
*/
2922
public function handle(ElasticaClient $elastica): void
3023
{
3124
if ($this->batch()?->cancelled()) {

src/Services/ModelEvent.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class ModelEvent
1717
public const EVENT_SAVED = 'saved';
1818
public const EVENT_RESTORED = 'restored';
1919
public const EVENT_DELETED = 'deleted';
20-
public const EVENTS = [self::EVENT_CREATED, self::EVENT_UPDATED, self::EVENT_SAVED, self::EVENT_RESTORED, self::EVENT_DELETED];
20+
public const EVENTS = [
21+
self::EVENT_CREATED, self::EVENT_UPDATED, self::EVENT_SAVED, self::EVENT_RESTORED, self::EVENT_DELETED, ];
2122

2223
public function __construct(protected IndexRepository $indexRepository)
2324
{
@@ -37,7 +38,9 @@ public function handle(string $event, Model $model): void
3738
$shouldBePresent = false;
3839
}
3940

40-
$shouldBePresent ? $this->ensureModelPresentInIndex($index, $model) : $this->ensureModelMissingFromIndex($index, $model);
41+
$shouldBePresent
42+
? $this->ensureModelPresentInIndex($index, $model)
43+
: $this->ensureModelMissingFromIndex($index, $model);
4144
}
4245
}
4346

@@ -53,7 +56,6 @@ protected function ensureModelMissingFromIndex(IndexInterface $index, Model $mod
5356
try {
5457
$index->getElasticaIndex()->deleteById($model->getElasticsearchId());
5558
} catch (NotFoundException) {
56-
//
5759
}
5860
}
5961

0 commit comments

Comments
 (0)