diff --git a/.travis.yml b/.travis.yml index 0756088..627d355 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ stages: - test php: - - '7.1' - '7.2' - '7.3' diff --git a/README.md b/README.md index cea98bf..255bf6f 100644 --- a/README.md +++ b/README.md @@ -609,3 +609,4 @@ Author and Contributors * [Quang Ngo](https://github.com/vanquang9387) * [David Higgins](https://github.com/zoul0813) * [Damon Williams](https://github.com/footballencarta) +* [David Palmer](https://github.com/dp88) diff --git a/composer.json b/composer.json index 521d8d2..39d8136 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "keywords": ["laravel", "dynamodb", "aws"], "require": { "aws/aws-sdk-php": "^3.0.0", - "illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*", - "illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*" + "illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.0.*", + "illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.0.*" }, "license": "MIT", "authors": [ diff --git a/src/ConditionAnalyzer/Analyzer.php b/src/ConditionAnalyzer/Analyzer.php index cdbb96a..9fb0740 100644 --- a/src/ConditionAnalyzer/Analyzer.php +++ b/src/ConditionAnalyzer/Analyzer.php @@ -5,6 +5,7 @@ use BaoPham\DynamoDb\ComparisonOperator; use BaoPham\DynamoDb\DynamoDbModel; use BaoPham\DynamoDb\H; +use Illuminate\Support\Arr; /** * Class ConditionAnalyzer @@ -71,7 +72,7 @@ public function isExactSearch() } foreach ($this->conditions as $condition) { - if (array_get($condition, 'type') !== ComparisonOperator::EQ) { + if (Arr::get($condition, 'type') !== ComparisonOperator::EQ) { return false; } } @@ -173,15 +174,15 @@ private function getIndex() $index = null; foreach ($this->model->getDynamoDbIndexKeys() as $name => $keysInfo) { - $conditionKeys = array_pluck($this->conditions, 'column'); + $conditionKeys = Arr::pluck($this->conditions, 'column'); $keys = array_values($keysInfo); if (count(array_intersect($conditionKeys, $keys)) === count($keys)) { if (!isset($this->indexName) || $this->indexName === $name) { $index = new Index( $name, - array_get($keysInfo, 'hash'), - array_get($keysInfo, 'range') + Arr::get($keysInfo, 'hash'), + Arr::get($keysInfo, 'range') ); break; diff --git a/src/DynamoDb/QueryBuilder.php b/src/DynamoDb/QueryBuilder.php index bad1008..bebbf12 100644 --- a/src/DynamoDb/QueryBuilder.php +++ b/src/DynamoDb/QueryBuilder.php @@ -6,6 +6,7 @@ use BadMethodCallException; use BaoPham\DynamoDb\DynamoDbClientInterface; use BaoPham\DynamoDb\RawDynamoDbQuery; +use Illuminate\Support\Str; /** * Class QueryBuilder @@ -109,7 +110,7 @@ public function prepare(DynamoDbClient $client = null) */ public function __call($method, $parameters) { - if (starts_with($method, 'set')) { + if (Str::startsWith($method, 'set')) { $key = array_reverse(explode('set', $method, 2))[0]; $this->query[$key] = current($parameters); diff --git a/src/DynamoDbClientService.php b/src/DynamoDbClientService.php index b567426..efa32df 100644 --- a/src/DynamoDbClientService.php +++ b/src/DynamoDbClientService.php @@ -4,6 +4,7 @@ use Aws\DynamoDb\DynamoDbClient; use Aws\DynamoDb\Marshaler; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Log; class DynamoDbClientService implements DynamoDbClientInterface @@ -43,7 +44,7 @@ public function getClient($connection = null) $config = config("dynamodb.connections.$connection", []); $config['version'] = '2012-08-10'; - $config['debug'] = $this->getDebugOptions(array_get($config, 'debug')); + $config['debug'] = $this->getDebugOptions(Arr::get($config, 'debug')); $client = new DynamoDbClient($config); diff --git a/src/DynamoDbModel.php b/src/DynamoDbModel.php index 658f027..abc0d84 100644 --- a/src/DynamoDbModel.php +++ b/src/DynamoDbModel.php @@ -5,6 +5,7 @@ use Exception; use DateTime; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Arr; /** * Class DynamoDbModel. @@ -183,7 +184,7 @@ public function saveAsync(array $options = []) $savePromise = $this->newQuery()->saveAsync(); $savePromise->then(function ($result) use ($create, $options) { - if (array_get($result, '@metadata.statusCode') === 200) { + if (Arr::get($result, '@metadata.statusCode') === 200) { $this->exists = true; $this->wasRecentlyCreated = $create; $this->fireModelEvent($create ? 'created' : 'updated', false); @@ -446,7 +447,7 @@ public function getMarshaler() public function __sleep() { return array_keys( - array_except(get_object_vars($this), ['marshaler', 'attributeFilter']) + Arr::except(get_object_vars($this), ['marshaler', 'attributeFilter']) ); } diff --git a/src/DynamoDbQueryBuilder.php b/src/DynamoDbQueryBuilder.php index ceef481..54e584b 100644 --- a/src/DynamoDbQueryBuilder.php +++ b/src/DynamoDbQueryBuilder.php @@ -10,6 +10,7 @@ use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\Scope; +use Illuminate\Support\Arr; class DynamoDbQueryBuilder { @@ -470,7 +471,7 @@ public function find($id, array $columns = []) $item = $query->prepare($this->client)->getItem(); - $item = array_get($item->toArray(), 'Item'); + $item = Arr::get($item->toArray(), 'Item'); if (empty($item)) { return null; @@ -601,7 +602,7 @@ public function removeAttribute(...$attributes) ->prepare($this->client) ->updateItem(); - $success = array_get($result, '@metadata.statusCode') === 200; + $success = Arr::get($result, '@metadata.statusCode') === 200; if ($success) { $this->model->setRawAttributes(DynamoDb::unmarshalItem($result->get('Attributes'))); @@ -618,7 +619,7 @@ public function delete() ->prepare($this->client) ->deleteItem(); - return array_get($result->toArray(), '@metadata.statusCode') === 200; + return Arr::get($result->toArray(), '@metadata.statusCode') === 200; } public function deleteAsync() @@ -638,7 +639,7 @@ public function save() ->prepare($this->client) ->putItem(); - return array_get($result, '@metadata.statusCode') === 200; + return Arr::get($result, '@metadata.statusCode') === 200; } public function saveAsync() @@ -710,7 +711,7 @@ protected function getAll( $res = $this->client->query($raw->query); } - $this->lastEvaluatedKey = array_get($res, 'LastEvaluatedKey'); + $this->lastEvaluatedKey = Arr::get($res, 'LastEvaluatedKey'); $iterator = $res['Items']; } diff --git a/src/Parsers/ConditionExpression.php b/src/Parsers/ConditionExpression.php index 0ae0ff3..e45df64 100644 --- a/src/Parsers/ConditionExpression.php +++ b/src/Parsers/ConditionExpression.php @@ -5,6 +5,7 @@ use BaoPham\DynamoDb\ComparisonOperator; use BaoPham\DynamoDb\NotSupportedException; use BaoPham\DynamoDb\Facades\DynamoDb; +use Illuminate\Support\Arr; class ConditionExpression { @@ -70,9 +71,9 @@ public function parse($where) $parsed = []; foreach ($where as $condition) { - $boolean = array_get($condition, 'boolean'); - $value = array_get($condition, 'value'); - $type = array_get($condition, 'type'); + $boolean = Arr::get($condition, 'boolean'); + $value = Arr::get($condition, 'value'); + $type = Arr::get($condition, 'type'); $prefix = ''; @@ -86,7 +87,7 @@ public function parse($where) } $parsed[] = $prefix . $this->parseCondition( - array_get($condition, 'column'), + Arr::get($condition, 'column'), $type, $value ); diff --git a/src/Parsers/KeyConditionExpression.php b/src/Parsers/KeyConditionExpression.php index 5d7ff04..fc1b7b7 100644 --- a/src/Parsers/KeyConditionExpression.php +++ b/src/Parsers/KeyConditionExpression.php @@ -3,12 +3,13 @@ namespace BaoPham\DynamoDb\Parsers; use BaoPham\DynamoDb\ComparisonOperator; +use Illuminate\Support\Arr; class KeyConditionExpression extends ConditionExpression { protected function getSupportedOperators() { - return array_only(static::OPERATORS, [ + return Arr::only(static::OPERATORS, [ ComparisonOperator::EQ, ComparisonOperator::LE, ComparisonOperator::LT, diff --git a/tests/DynamoDbCompositeModelTest.php b/tests/DynamoDbCompositeModelTest.php index 4979c35..4523e29 100644 --- a/tests/DynamoDbCompositeModelTest.php +++ b/tests/DynamoDbCompositeModelTest.php @@ -6,6 +6,8 @@ use BaoPham\DynamoDb\Facades\DynamoDb; use BaoPham\DynamoDb\RawDynamoDbQuery; use \Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; /** * Class DynamoDbCompositeModelTest @@ -22,7 +24,7 @@ protected function getTestModel() public function testCreateRecord() { $this->testModel->id = 'id1'; - $this->testModel->id2 = str_random(36); + $this->testModel->id2 = Str::random(36); $this->testModel->name = 'Test Create'; $this->testModel->count = 1; $this->testModel->save(); @@ -45,7 +47,7 @@ public function testCreateRecord() public function testCreateAsyncRecord() { $this->testModel->id = 'id1'; - $this->testModel->id2 = str_random(36); + $this->testModel->id2 = Str::random(36); $this->testModel->name = 'Test Create Async'; $this->testModel->count = 1; $this->testModel->saveAsync()->wait(); @@ -68,9 +70,9 @@ public function testCreateAsyncRecord() public function testFindRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); + $seedName = Arr::get($seed, 'name.S'); $item = $this->testModel->find(['id' => $seedId, 'id2' => $seedId2]); @@ -111,9 +113,9 @@ public function testFindMultiple() public function testFindOrFailRecordPass() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); + $seedName = Arr::get($seed, 'name.S'); $item = $this->testModel->findOrFail(['id' => $seedId, 'id2' => $seedId2]); @@ -146,9 +148,9 @@ public function testFindOrFailMultiple() public function testFirstOrFailRecordPass() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); + $seedName = Arr::get($seed, 'name.S'); $query = $this->testModel ->where('id', $seedId) @@ -180,8 +182,8 @@ public function testFirstOrFailRecordFail() public function testUpdateRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $newName = 'New Name'; $this->testModel = $this->testModel->find(['id' => $seedId, 'id2' => $seedId2]); @@ -199,14 +201,14 @@ public function testUpdateRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testUpdateAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $newName = 'New Name'; $this->testModel = $this->testModel->find(['id' => $seedId, 'id2' => $seedId2]); @@ -222,14 +224,14 @@ public function testUpdateAsyncRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testSaveRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $newName = 'New Name to be saved'; $this->testModel = $this->testModel->find(['id' => $seedId, 'id2' => $seedId2]); @@ -247,14 +249,14 @@ public function testSaveRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testSaveAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $newName = 'New Name to be saved asynchronously'; $this->testModel = $this->testModel->find(['id' => $seedId, 'id2' => $seedId2]); @@ -272,14 +274,14 @@ public function testSaveAsyncRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testDeleteRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $this->testModel->find(['id' => $seedId, 'id2' => $seedId2])->delete(); @@ -299,8 +301,8 @@ public function testDeleteRecord() public function testDeleteAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedId2 = array_get($seed, 'id2.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedId2 = Arr::get($seed, 'id2.S'); $this->testModel->find(['id' => $seedId, 'id2' => $seedId2])->deleteAsync()->wait(); @@ -451,7 +453,7 @@ public function testSetIndexManually() ->withIndex('id_author_index') ->toDynamoDbQuery(); - $this->assertEquals('id_author_index', array_get($raw->query, 'IndexName')); + $this->assertEquals('id_author_index', Arr::get($raw->query, 'IndexName')); $this->assertEquals('Query', $raw->op); } @@ -756,11 +758,11 @@ public function seed($attributes = [], $exclude = []) { $item = [ 'id' => ['S' => 'id1'], - 'id2' => ['S' => str_random(36)], - 'name' => ['S' => str_random(36)], - 'description' => ['S' => str_random(256)], + 'id2' => ['S' => Str::random(36)], + 'name' => ['S' => Str::random(36)], + 'description' => ['S' => Str::random(256)], 'count' => ['N' => rand()], - 'author' => ['S' => str_random()], + 'author' => ['S' => Str::random()], 'nested' => [ 'M' => [ 'foo' => ['S' => 'bar'], @@ -777,7 +779,7 @@ public function seed($attributes = [], $exclude = []) ]; $item = array_merge($item, $attributes); - $item = array_except($item, $exclude); + $item = Arr::except($item, $exclude); $this->getClient()->putItem([ 'TableName' => $this->testModel->getTable(), diff --git a/tests/DynamoDbNonCompositeModelTest.php b/tests/DynamoDbNonCompositeModelTest.php index d5b8825..13f1ff0 100644 --- a/tests/DynamoDbNonCompositeModelTest.php +++ b/tests/DynamoDbNonCompositeModelTest.php @@ -5,6 +5,8 @@ use BaoPham\DynamoDb\DynamoDbModel; use BaoPham\DynamoDb\RawDynamoDbQuery; use \Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; /** * Class DynamoDbNonCompositeModelTest @@ -20,7 +22,7 @@ protected function getTestModel() public function testCreateRecord() { - $this->testModel->id = str_random(36); + $this->testModel->id = Str::random(36); $this->testModel->name = 'Test Create'; $this->testModel->count = 1; $this->testModel->save(); @@ -40,7 +42,7 @@ public function testCreateRecord() public function testCreateAsyncRecord() { - $this->testModel->id = str_random(36); + $this->testModel->id = Str::random(36); $this->testModel->name = 'Test Create Async'; $this->testModel->count = 1; $this->testModel->saveAsync()->wait(); @@ -61,8 +63,8 @@ public function testCreateAsyncRecord() public function testFindRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedName = Arr::get($seed, 'name.S'); $item = $this->testModel->find($seedId); @@ -95,8 +97,8 @@ public function testFindMultiple() public function testFindOrFailRecordPass() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedName = Arr::get($seed, 'name.S'); $item = $this->testModel->findOrFail($seedId); @@ -121,8 +123,8 @@ public function testFindOrFailMultiple() public function testFirstOrFailRecordPass() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); - $seedName = array_get($seed, 'name.S'); + $seedId = Arr::get($seed, 'id.S'); + $seedName = Arr::get($seed, 'name.S'); $query = $this->testModel ->where('id', $seedId); @@ -161,7 +163,7 @@ public function testGetAllRecords() public function testUpdateRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $newName = 'New Name'; $this->testModel = $this->testModel->find($seedId); @@ -178,13 +180,13 @@ public function testUpdateRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testUpdateAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $newName = 'New Name'; $this->testModel = $this->testModel->find($seedId); @@ -199,13 +201,13 @@ public function testUpdateAsyncRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testSaveRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $newName = 'New Name to be saved'; $this->testModel = $this->testModel->find($seedId); @@ -222,13 +224,13 @@ public function testSaveRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testSaveAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $newName = 'New Name to be saved asynchronously'; $this->testModel = $this->testModel->find($seedId); @@ -245,13 +247,13 @@ public function testSaveAsyncRecord() $record = $this->getClient()->getItem($query)->toArray(); - $this->assertEquals($newName, array_get($record, 'Item.name.S')); + $this->assertEquals($newName, Arr::get($record, 'Item.name.S')); } public function testDeleteRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $this->testModel->find($seedId)->delete(); @@ -270,7 +272,7 @@ public function testDeleteRecord() public function testDeleteAsyncRecord() { $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $this->testModel->find($seedId)->deleteAsync()->wait(); @@ -492,7 +494,7 @@ public function testGetFirstRecord() $items = $this->testModel->first(); - $this->assertEquals(array_get($firstItem, 'id.S'), $items->id); + $this->assertEquals(Arr::get($firstItem, 'id.S'), $items->id); } public function testChainedMethods() @@ -1194,11 +1196,11 @@ protected function assertRemoveAttributes($item) public function seed($attributes = [], $exclude = []) { $item = [ - 'id' => ['S' => str_random(36)], - 'name' => ['S' => str_random(36)], - 'description' => ['S' => str_random(256)], + 'id' => ['S' => Str::random(36)], + 'name' => ['S' => Str::random(36)], + 'description' => ['S' => Str::random(256)], 'count' => ['N' => rand()], - 'author' => ['S' => str_random()], + 'author' => ['S' => Str::random()], 'nested' => [ 'M' => [ 'foo' => ['S' => 'bar'], @@ -1215,7 +1217,7 @@ public function seed($attributes = [], $exclude = []) ]; $item = array_merge($item, $attributes); - $item = array_except($item, $exclude); + $item = Arr::except($item, $exclude); $this->getClient()->putItem([ 'TableName' => $this->testModel->getTable(), diff --git a/tests/DynamoDbQueryScopeTest.php b/tests/DynamoDbQueryScopeTest.php index b8cafa4..21a827f 100644 --- a/tests/DynamoDbQueryScopeTest.php +++ b/tests/DynamoDbQueryScopeTest.php @@ -3,6 +3,7 @@ namespace BaoPham\DynamoDb\Tests; use BaoPham\DynamoDb\DynamoDbQueryBuilder; +use Illuminate\Support\Str; /** * Class DynamoDbQueryScopeTest @@ -114,11 +115,11 @@ public function testChunkWithDynamicLocalScope() public function seed($attributes = []) { $item = [ - 'id' => ['S' => str_random(36)], - 'name' => ['S' => str_random(36)], - 'description' => ['S' => str_random(256)], + 'id' => ['S' => Str::random(36)], + 'name' => ['S' => Str::random(36)], + 'description' => ['S' => Str::random(256)], 'count' => ['N' => rand()], - 'author' => ['S' => str_random()], + 'author' => ['S' => Str::random()], ]; $item = array_merge($item, $attributes); diff --git a/tests/DynamoDbTimestampTest.php b/tests/DynamoDbTimestampTest.php index 74344f4..8353abe 100644 --- a/tests/DynamoDbTimestampTest.php +++ b/tests/DynamoDbTimestampTest.php @@ -3,6 +3,8 @@ namespace BaoPham\DynamoDb\Tests; use Carbon\Carbon; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; /** * Class DynamoDbTimestampTest @@ -20,7 +22,7 @@ public function testCreateRecord() { Carbon::setTestNow(Carbon::create(2017, 06, 24, 5, 30, 0)); $now = new Carbon; - $this->testModel->id = str_random(36); + $this->testModel->id = Str::random(36); $this->testModel->name = 'Test Create'; $this->testModel->count = 1; $this->testModel->save(); @@ -43,7 +45,7 @@ public function testUpdateRecord() Carbon::setTestNow(Carbon::create(2017, 03, 01, 8, 30, 0)); $now = new Carbon(); $seed = $this->seed(); - $seedId = array_get($seed, 'id.S'); + $seedId = Arr::get($seed, 'id.S'); $newName = 'New Name'; $model = $this->testModel->find($seedId); @@ -67,11 +69,11 @@ public function testUpdateRecord() public function seed($attributes = []) { $item = [ - 'id' => ['S' => str_random(36)], - 'name' => ['S' => str_random(36)], - 'description' => ['S' => str_random(256)], + 'id' => ['S' => Str::random(36)], + 'name' => ['S' => Str::random(36)], + 'description' => ['S' => Str::random(256)], 'count' => ['N' => rand()], - 'author' => ['S' => str_random()], + 'author' => ['S' => Str::random()], ]; $item = array_merge($item, $attributes); diff --git a/tests/Parsers/ConditionExpressionTest.php b/tests/Parsers/ConditionExpressionTest.php index aa933f3..021bcab 100644 --- a/tests/Parsers/ConditionExpressionTest.php +++ b/tests/Parsers/ConditionExpressionTest.php @@ -8,6 +8,7 @@ use BaoPham\DynamoDb\Parsers\ExpressionAttributeValues; use BaoPham\DynamoDb\Parsers\Placeholder; use PHPUnit\Framework\TestCase; +use Illuminate\Support\Arr; class ConditionExpressionTest extends TestCase { @@ -156,7 +157,7 @@ public function testParse() $this->assertEquals(['BOOL' => true], $this->values->get(':a13')); $this->assertEquals(['S' => 'android'], $this->values->get(':a14')); - $columns = array_filter(array_pluck($where, 'column')); + $columns = array_filter(Arr::pluck($where, 'column')); foreach ($columns as $column) { $this->assertEquals($column, $this->names->get("#{$column}"));