Skip to content

Commit cd0cda7

Browse files
limenetgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 78fd572 commit cd0cda7

File tree

13 files changed

+36
-20
lines changed

13 files changed

+36
-20
lines changed

src/Client/ElasticaClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class ElasticaClient
1111
{
1212
protected Client $client;
13+
1314
protected static ?bool $listenToEvents = null;
1415

1516
public function __construct()

src/Commands/IndexCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function handle(): int
2929
{
3030
foreach ($this->indexRepository->all() as $indexConfig) {
3131
if (
32-
!empty($this->argument('index'))
33-
&& !in_array($indexConfig->getName(), $this->argument('index'), true)
32+
! empty($this->argument('index'))
33+
&& ! in_array($indexConfig->getName(), $this->argument('index'), true)
3434
) {
3535
continue;
3636
}
@@ -43,8 +43,9 @@ public function handle(): int
4343
$lock->forceRelease();
4444
}
4545

46-
if (!$lock->get()) {
46+
if (! $lock->get()) {
4747
$this->warn('Not indexing as another job is still running.');
48+
4849
continue;
4950
}
5051

src/Index/AbstractIndex.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public function getElasticaIndex(): Index
5858
}
5959

6060
/**
61-
* @param int $size Max number of elements to be retrieved aka limit
62-
* @param int $from Number of elements to skip from the beginning aka offset
63-
*
61+
* @param int $size Max number of elements to be retrieved aka limit
62+
* @param int $from Number of elements to skip from the beginning aka offset
6463
* @return Model[]
6564
*/
6665
public function searchForElements(Query\AbstractQuery $query, int $size = 10, int $from = 0): array
@@ -124,7 +123,7 @@ final public function hasBlueGreenIndices(): bool
124123

125124
final public function getBlueGreenActiveSuffix(): string
126125
{
127-
if (!$this->hasBlueGreenIndices()) {
126+
if (! $this->hasBlueGreenIndices()) {
128127
throw new BlueGreenIndicesIncorrectlySetupException();
129128
}
130129

@@ -139,7 +138,7 @@ final public function getBlueGreenActiveSuffix(): string
139138

140139
$suffix = substr((string) array_keys($aliases)[0], strlen($this->getName()));
141140

142-
if (!in_array($suffix, self::INDEX_SUFFIXES, true)) {
141+
if (! in_array($suffix, self::INDEX_SUFFIXES, true)) {
143142
throw new BlueGreenIndicesIncorrectlySetupException();
144143
}
145144

src/Index/IndexInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ interface IndexInterface
1717
* The suffix for the blue index.
1818
*/
1919
public const INDEX_SUFFIX_BLUE = '--blue';
20+
2021
/**
2122
* The suffix for the green index.
2223
*/
2324
public const INDEX_SUFFIX_GREEN = '--green';
25+
2426
/**
2527
* List of valid index suffixes.
2628
*/
2729
public const INDEX_SUFFIXES = [self::INDEX_SUFFIX_BLUE, self::INDEX_SUFFIX_GREEN];
2830

2931
public const DOCUMENT_MODEL_ID = '__id';
32+
3033
public const DOCUMENT_MODEL_CLASS = '__class';
3134

3235
/**

src/Jobs/PopulateBatchIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function handle(): void
4242
/** @var ElasticsearchableInterface[] $records */
4343
$records = $this->indexDocument::offset($this->offset)->limit($this->limit)->get();
4444
foreach ($records as $record) {
45-
if (!$record->shouldIndex($this->indexConfig)) {
45+
if (! $record->shouldIndex($this->indexConfig)) {
4646
continue;
4747
}
4848

src/Jobs/SetupIndex.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function handle(ElasticaClient $elastica): void
3434

3535
private function migrate(ElasticaClient $elastica): void
3636
{
37-
if (!$this->indexConfig->hasBlueGreenIndices()) {
37+
if (! $this->indexConfig->hasBlueGreenIndices()) {
3838
return;
3939
}
4040

@@ -71,7 +71,7 @@ private function cleanup(ElasticaClient $elastica): void
7171
$aliasIndex->delete();
7272
}
7373

74-
if (!$aliasIndex->exists()) {
74+
if (! $aliasIndex->exists()) {
7575
$aliasIndex->create($this->indexConfig->getCreateArguments());
7676
}
7777
}

src/LaravelElasticaBridgeServiceProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
namespace Limenet\LaravelElasticaBridge;
66

77
use Illuminate\Database\Eloquent\Model;
8-
98
use function Illuminate\Events\queueable;
10-
119
use Illuminate\Support\Facades\Event;
1210
use Limenet\LaravelElasticaBridge\Client\ElasticaClient;
1311
use Limenet\LaravelElasticaBridge\Commands\IndexCommand;
@@ -49,7 +47,7 @@ public function packageBooted(): void
4947
Event::listen(
5048
sprintf('eloquent.%s:*', $name),
5149
queueable(function (string $event, array $models) use ($name): void {
52-
if (!resolve(ElasticaClient::class)->listensToEvents()) {
50+
if (! resolve(ElasticaClient::class)->listensToEvents()) {
5351
return;
5452
}
5553

src/Services/ModelEventListener.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
class ModelEventListener
1414
{
1515
public const EVENT_CREATED = 'created';
16+
1617
public const EVENT_UPDATED = 'updated';
18+
1719
public const EVENT_SAVED = 'saved';
20+
1821
public const EVENT_RESTORED = 'restored';
22+
1923
public const EVENT_DELETED = 'deleted';
24+
2025
public const EVENTS = [
2126
self::EVENT_CREATED,
2227
self::EVENT_UPDATED,
@@ -29,17 +34,17 @@ public function __construct(protected IndexRepository $indexRepository)
2934
{
3035
}
3136

32-
/** @param ElasticsearchableInterface&Model $model */
37+
/** @param ElasticsearchableInterface&Model $model */
3338
public function handle(string $event, Model $model): void
3439
{
3540
foreach ($this->matchingIndicesForElement($model) as $index) {
36-
if (!$index->getElasticaIndex()->exists()) {
41+
if (! $index->getElasticaIndex()->exists()) {
3742
continue;
3843
}
3944

4045
$shouldBePresent = true;
4146

42-
if (!$model->shouldIndex($index) || $event === self::EVENT_DELETED) {
47+
if (! $model->shouldIndex($index) || $event === self::EVENT_DELETED) {
4348
$shouldBePresent = false;
4449
}
4550

@@ -49,13 +54,13 @@ public function handle(string $event, Model $model): void
4954
}
5055
}
5156

52-
/** @param ElasticsearchableInterface&Model $model */
57+
/** @param ElasticsearchableInterface&Model $model */
5358
protected function ensureModelPresentInIndex(IndexInterface $index, Model $model): void
5459
{
5560
$index->getElasticaIndex()->addDocument($model->toElasticaDocument($index));
5661
}
5762

58-
/** @param ElasticsearchableInterface&Model $model */
63+
/** @param ElasticsearchableInterface&Model $model */
5964
protected function ensureModelMissingFromIndex(IndexInterface $index, Model $model): void
6065
{
6166
try {

tests/Feature/TestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
class TestCase extends TestsTestCase
1818
{
1919
protected CustomerIndex $customerIndex;
20+
2021
protected OrderIndex $orderIndex;
22+
2123
protected ProductIndex $productIndex;
24+
2225
protected IndexRepository $indexRepository;
26+
2327
protected ElasticaClient $elasticaClient;
2428

2529
protected function setUp(): void

tests/Unit/IndexTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
class IndexTest extends TestCase
1818
{
1919
protected CustomerIndex $customerIndex;
20+
2021
protected ProductIndex $productIndex;
2122

2223
protected function setUp(): void

tests/Unit/ModelTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class ModelTest extends TestCase
1515
{
1616
protected CustomerIndex $customerIndex;
17+
1718
protected ProductIndex $productIndex;
1819

1920
protected function setUp(): void

tests/Unit/RepositoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
class RepositoryTest extends TestCase
1313
{
1414
protected CustomerIndex $customerIndex;
15+
1516
protected ProductIndex $productIndex;
17+
1618
protected IndexRepository $indexRepository;
1719

1820
protected function setUp(): void

tests/database/migrations/SetupTables.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
88

9-
return new class() extends Migration {
9+
return new class() extends Migration
10+
{
1011
public function up(): void
1112
{
1213
Schema::create('customers', function (Blueprint $table): void {

0 commit comments

Comments
 (0)