Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 3265a33

Browse files
committed
Do not use array helpers
1 parent 7999570 commit 3265a33

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

src/Builders/FilterBuilder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ScoutElastic\Builders;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Support\Arr;
67
use Laravel\Scout\Builder;
78

89
class FilterBuilder extends Builder
@@ -515,7 +516,7 @@ public function select($fields)
515516
{
516517
$this->select = array_merge(
517518
$this->select,
518-
array_wrap($fields)
519+
Arr::wrap($fields)
519520
);
520521

521522
return $this;
@@ -540,7 +541,7 @@ public function withTrashed()
540541
{
541542
$this->wheres['must'] = collect($this->wheres['must'])
542543
->filter(function ($item) {
543-
return array_get($item, 'term.__soft_deleted') !== 0;
544+
return Arr::get($item, 'term.__soft_deleted') !== 0;
544545
})
545546
->values()
546547
->all();

src/ElasticEngine.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ScoutElastic;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Support\Facades\Artisan;
67
use Laravel\Scout\Builder;
78
use Laravel\Scout\Engines\Engine;
@@ -297,7 +298,7 @@ public function map(Builder $builder, $results, $model)
297298

298299
$primaryKey = $model->getKeyName();
299300

300-
$columns = array_get($results, '_payload.body._source');
301+
$columns = Arr::get($results, '_payload.body._source');
301302

302303
if (is_null($columns)) {
303304
$columns = ['*'];

src/Payloads/RawPayload.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace ScoutElastic\Payloads;
44

5+
use Illuminate\Support\Arr;
6+
57
class RawPayload
68
{
79
/**
@@ -21,7 +23,7 @@ class RawPayload
2123
public function set($key, $value)
2224
{
2325
if (!is_null($key)) {
24-
array_set($this->payload, $key, $value);
26+
Arr::set($this->payload, $key, $value);
2527
}
2628

2729
return $this;
@@ -67,7 +69,7 @@ public function setIfNotNull($key, $value)
6769
*/
6870
public function has($key)
6971
{
70-
return array_has($this->payload, $key);
72+
return Arr::has($this->payload, $key);
7173
}
7274

7375
/**
@@ -80,15 +82,15 @@ public function has($key)
8082
public function add($key, $value)
8183
{
8284
if (!is_null($key)) {
83-
$currentValue = array_get($this->payload, $key, []);
85+
$currentValue = Arr::get($this->payload, $key, []);
8486

8587
if (!is_array($currentValue)) {
86-
$currentValue = array_wrap($currentValue);
88+
$currentValue = Arr::wrap($currentValue);
8789
}
8890

8991
$currentValue[] = $value;
9092

91-
array_set($this->payload, $key, $currentValue);
93+
Arr::set($this->payload, $key, $currentValue);
9294
}
9395

9496
return $this;
@@ -119,6 +121,6 @@ public function addIfNotEmpty($key, $value)
119121
*/
120122
public function get($key = null, $default = null)
121123
{
122-
return array_get($this->payload, $key, $default);
124+
return Arr::get($this->payload, $key, $default);
123125
}
124126
}

src/Searchable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ScoutElastic;
44

5+
use Illuminate\Support\Arr;
56
use Laravel\Scout\Searchable as ScoutSearchable;
67
use ScoutElastic\Builders\FilterBuilder;
78
use ScoutElastic\Builders\SearchBuilder;
@@ -73,7 +74,7 @@ public function getMapping()
7374
$mapping = $this->mapping ?? [];
7475

7576
if ($this::usesSoftDelete() && config('scout.soft_delete', false)) {
76-
array_set($mapping, 'properties.__soft_deleted', ['type' => 'integer']);
77+
Arr::set($mapping, 'properties.__soft_deleted', ['type' => 'integer']);
7778
}
7879

7980
return $mapping;

tests/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Config
1515
*/
1616
public static function set($key, $value)
1717
{
18-
array_set(static::$values, $key, $value);
18+
Arr::set(static::$values, $key, $value);
1919
}
2020

2121
/**
@@ -25,7 +25,7 @@ public static function set($key, $value)
2525
*/
2626
public static function get($key = null, $default = null)
2727
{
28-
return array_get(static::$values, $key, $default);
28+
return Arr::get(static::$values, $key, $default);
2929
}
3030

3131
/**
@@ -39,4 +39,4 @@ public static function reset(array $values = [])
3939
static::set($key, $value);
4040
}
4141
}
42-
}
42+
}

0 commit comments

Comments
 (0)