Skip to content

Commit 6f16f9d

Browse files
dp88baopham
authored andcommitted
Laravel 6.0 Support (#203)
* Laravel 6.0 Support * Remove PHP 7.1 Step from Travis Since PHP 7.1 will no longer be actively maintained after December of this year.
1 parent 77239f9 commit 6f16f9d

15 files changed

+104
-89
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ stages:
77
- test
88

99
php:
10-
- '7.1'
1110
- '7.2'
1211
- '7.3'
1312

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,4 @@ Author and Contributors
609609
* [Quang Ngo](https://github.com/vanquang9387)
610610
* [David Higgins](https://github.com/zoul0813)
611611
* [Damon Williams](https://github.com/footballencarta)
612+
* [David Palmer](https://github.com/dp88)

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"keywords": ["laravel", "dynamodb", "aws"],
55
"require": {
66
"aws/aws-sdk-php": "^3.0.0",
7-
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
8-
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*"
7+
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.0.*",
8+
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.0.*"
99
},
1010
"license": "MIT",
1111
"authors": [

src/ConditionAnalyzer/Analyzer.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BaoPham\DynamoDb\ComparisonOperator;
66
use BaoPham\DynamoDb\DynamoDbModel;
77
use BaoPham\DynamoDb\H;
8+
use Illuminate\Support\Arr;
89

910
/**
1011
* Class ConditionAnalyzer
@@ -71,7 +72,7 @@ public function isExactSearch()
7172
}
7273

7374
foreach ($this->conditions as $condition) {
74-
if (array_get($condition, 'type') !== ComparisonOperator::EQ) {
75+
if (Arr::get($condition, 'type') !== ComparisonOperator::EQ) {
7576
return false;
7677
}
7778
}
@@ -173,15 +174,15 @@ private function getIndex()
173174
$index = null;
174175

175176
foreach ($this->model->getDynamoDbIndexKeys() as $name => $keysInfo) {
176-
$conditionKeys = array_pluck($this->conditions, 'column');
177+
$conditionKeys = Arr::pluck($this->conditions, 'column');
177178
$keys = array_values($keysInfo);
178179

179180
if (count(array_intersect($conditionKeys, $keys)) === count($keys)) {
180181
if (!isset($this->indexName) || $this->indexName === $name) {
181182
$index = new Index(
182183
$name,
183-
array_get($keysInfo, 'hash'),
184-
array_get($keysInfo, 'range')
184+
Arr::get($keysInfo, 'hash'),
185+
Arr::get($keysInfo, 'range')
185186
);
186187

187188
break;

src/DynamoDb/QueryBuilder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use BadMethodCallException;
77
use BaoPham\DynamoDb\DynamoDbClientInterface;
88
use BaoPham\DynamoDb\RawDynamoDbQuery;
9+
use Illuminate\Support\Str;
910

1011
/**
1112
* Class QueryBuilder
@@ -109,7 +110,7 @@ public function prepare(DynamoDbClient $client = null)
109110
*/
110111
public function __call($method, $parameters)
111112
{
112-
if (starts_with($method, 'set')) {
113+
if (Str::startsWith($method, 'set')) {
113114
$key = array_reverse(explode('set', $method, 2))[0];
114115
$this->query[$key] = current($parameters);
115116

src/DynamoDbClientService.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Aws\DynamoDb\DynamoDbClient;
66
use Aws\DynamoDb\Marshaler;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Facades\Log;
89

910
class DynamoDbClientService implements DynamoDbClientInterface
@@ -43,7 +44,7 @@ public function getClient($connection = null)
4344

4445
$config = config("dynamodb.connections.$connection", []);
4546
$config['version'] = '2012-08-10';
46-
$config['debug'] = $this->getDebugOptions(array_get($config, 'debug'));
47+
$config['debug'] = $this->getDebugOptions(Arr::get($config, 'debug'));
4748

4849
$client = new DynamoDbClient($config);
4950

src/DynamoDbModel.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Exception;
66
use DateTime;
77
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Support\Arr;
89

910
/**
1011
* Class DynamoDbModel.
@@ -183,7 +184,7 @@ public function saveAsync(array $options = [])
183184
$savePromise = $this->newQuery()->saveAsync();
184185

185186
$savePromise->then(function ($result) use ($create, $options) {
186-
if (array_get($result, '@metadata.statusCode') === 200) {
187+
if (Arr::get($result, '@metadata.statusCode') === 200) {
187188
$this->exists = true;
188189
$this->wasRecentlyCreated = $create;
189190
$this->fireModelEvent($create ? 'created' : 'updated', false);
@@ -446,7 +447,7 @@ public function getMarshaler()
446447
public function __sleep()
447448
{
448449
return array_keys(
449-
array_except(get_object_vars($this), ['marshaler', 'attributeFilter'])
450+
Arr::except(get_object_vars($this), ['marshaler', 'attributeFilter'])
450451
);
451452
}
452453

src/DynamoDbQueryBuilder.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Contracts\Support\Arrayable;
1111
use Illuminate\Database\Eloquent\ModelNotFoundException;
1212
use Illuminate\Database\Eloquent\Scope;
13+
use Illuminate\Support\Arr;
1314

1415
class DynamoDbQueryBuilder
1516
{
@@ -470,7 +471,7 @@ public function find($id, array $columns = [])
470471

471472
$item = $query->prepare($this->client)->getItem();
472473

473-
$item = array_get($item->toArray(), 'Item');
474+
$item = Arr::get($item->toArray(), 'Item');
474475

475476
if (empty($item)) {
476477
return null;
@@ -601,7 +602,7 @@ public function removeAttribute(...$attributes)
601602
->prepare($this->client)
602603
->updateItem();
603604

604-
$success = array_get($result, '@metadata.statusCode') === 200;
605+
$success = Arr::get($result, '@metadata.statusCode') === 200;
605606

606607
if ($success) {
607608
$this->model->setRawAttributes(DynamoDb::unmarshalItem($result->get('Attributes')));
@@ -618,7 +619,7 @@ public function delete()
618619
->prepare($this->client)
619620
->deleteItem();
620621

621-
return array_get($result->toArray(), '@metadata.statusCode') === 200;
622+
return Arr::get($result->toArray(), '@metadata.statusCode') === 200;
622623
}
623624

624625
public function deleteAsync()
@@ -638,7 +639,7 @@ public function save()
638639
->prepare($this->client)
639640
->putItem();
640641

641-
return array_get($result, '@metadata.statusCode') === 200;
642+
return Arr::get($result, '@metadata.statusCode') === 200;
642643
}
643644

644645
public function saveAsync()
@@ -710,7 +711,7 @@ protected function getAll(
710711
$res = $this->client->query($raw->query);
711712
}
712713

713-
$this->lastEvaluatedKey = array_get($res, 'LastEvaluatedKey');
714+
$this->lastEvaluatedKey = Arr::get($res, 'LastEvaluatedKey');
714715
$iterator = $res['Items'];
715716
}
716717

src/Parsers/ConditionExpression.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BaoPham\DynamoDb\ComparisonOperator;
66
use BaoPham\DynamoDb\NotSupportedException;
77
use BaoPham\DynamoDb\Facades\DynamoDb;
8+
use Illuminate\Support\Arr;
89

910
class ConditionExpression
1011
{
@@ -70,9 +71,9 @@ public function parse($where)
7071
$parsed = [];
7172

7273
foreach ($where as $condition) {
73-
$boolean = array_get($condition, 'boolean');
74-
$value = array_get($condition, 'value');
75-
$type = array_get($condition, 'type');
74+
$boolean = Arr::get($condition, 'boolean');
75+
$value = Arr::get($condition, 'value');
76+
$type = Arr::get($condition, 'type');
7677

7778
$prefix = '';
7879

@@ -86,7 +87,7 @@ public function parse($where)
8687
}
8788

8889
$parsed[] = $prefix . $this->parseCondition(
89-
array_get($condition, 'column'),
90+
Arr::get($condition, 'column'),
9091
$type,
9192
$value
9293
);

src/Parsers/KeyConditionExpression.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace BaoPham\DynamoDb\Parsers;
44

55
use BaoPham\DynamoDb\ComparisonOperator;
6+
use Illuminate\Support\Arr;
67

78
class KeyConditionExpression extends ConditionExpression
89
{
910
protected function getSupportedOperators()
1011
{
11-
return array_only(static::OPERATORS, [
12+
return Arr::only(static::OPERATORS, [
1213
ComparisonOperator::EQ,
1314
ComparisonOperator::LE,
1415
ComparisonOperator::LT,

0 commit comments

Comments
 (0)