@@ -18,8 +18,8 @@ |
||
18 | 18 | $client = $this->getClient(); |
19 | 19 | } |
20 | 20 | return (new Finder($client)) |
21 | - ->database($this->getDatabaseName()) |
|
22 | - ->from($this->getResourceName()); |
|
21 | + ->database($this->getDatabaseName()) |
|
22 | + ->from($this->getResourceName()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function validateUniqueFields() |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | if ((int)$res->hits() > 0) { |
33 | 33 | $results = json_decode($res->rawResponse())->results; |
34 | 34 | $message = $results[0]->{$this->primaryKey} === $this->getPrimaryKeyValue() ? |
35 | - 'Primary key collision' : |
|
36 | - 'Unique constraint violation'; |
|
35 | + 'Primary key collision' : 'Unique constraint violation'; |
|
37 | 36 | throw new RestException( |
38 | 37 | $message, |
39 | 38 | ['resourceName' => $this->resourceName, 'confilct' => $results[0]] |
@@ -44,7 +43,7 @@ discard block |
||
44 | 43 | private function getUniqueFieldQuery($query, $uniqueFields) |
45 | 44 | { |
46 | 45 | // @codeCoverageIgnoreStart |
47 | - $query->where(function ($query) use ($uniqueFields) { |
|
46 | + $query->where(function($query) use ($uniqueFields) { |
|
48 | 47 | foreach ($uniqueFields as $fieldName) { |
49 | 48 | if (property_exists($this->resource, $fieldName)) { |
50 | 49 | $query->orWhere($fieldName, '==', $this->resource->{$fieldName}); |
@@ -57,7 +56,7 @@ discard block |
||
57 | 56 | |
58 | 57 | public function query() |
59 | 58 | { |
60 | - $query = $this->database->getClient()->database($this->database->getDatabaseName().'.'.$this->resourceName); |
|
59 | + $query = $this->database->getClient()->database($this->database->getDatabaseName() . '.' . $this->resourceName); |
|
61 | 60 | return $query; |
62 | 61 | } |
63 | 62 | } |
@@ -18,8 +18,8 @@ |
||
18 | 18 | $client = $this->getClient(); |
19 | 19 | } |
20 | 20 | return (new Finder($client)) |
21 | - ->database($this->getDatabaseName()) |
|
22 | - ->from($this->getResourceName()); |
|
21 | + ->database($this->getDatabaseName()) |
|
22 | + ->from($this->getResourceName()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function validateUniqueFields() |
@@ -40,10 +40,10 @@ |
||
40 | 40 | |
41 | 41 | protected function addWhereGroup($collection, $conditions, $logical) |
42 | 42 | { |
43 | - /** |
|
44 | - * @codeCoverageIgnore |
|
45 | - * Passing anonymous function to Clusterpoint API |
|
46 | - */ |
|
43 | + /** |
|
44 | + * @codeCoverageIgnore |
|
45 | + * Passing anonymous function to Clusterpoint API |
|
46 | + */ |
|
47 | 47 | return function ($collection) use ($conditions, $logical) { |
48 | 48 | $this->parseWhere($collection, $conditions, $logical); |
49 | 49 | }; |
@@ -42,6 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | + /** |
|
46 | + * @param \Clusterpoint\Instance\Service $collection |
|
47 | + */ |
|
45 | 48 | protected function configQuery($collection) |
46 | 49 | { |
47 | 50 | $this->setLimit($collection); |
@@ -90,6 +93,9 @@ discard block |
||
90 | 93 | }; |
91 | 94 | } |
92 | 95 | |
96 | + /** |
|
97 | + * @param string $nextLogical |
|
98 | + */ |
|
93 | 99 | protected function parseWhereGroup($logical, $collection, $condition, $nextLogical) |
94 | 100 | { |
95 | 101 | if ($logical === '||') { |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | ); |
61 | 61 | } |
62 | 62 | $collection = $this->client->database( |
63 | - $this->queryConfiguration->databaseName. |
|
64 | - '.'. |
|
63 | + $this->queryConfiguration->databaseName . |
|
64 | + '.' . |
|
65 | 65 | $this->queryConfiguration->from |
66 | 66 | ); |
67 | 67 | $this->configQuery($collection); |
68 | 68 | $items = json_decode(json_encode($collection->get()->toArray())); |
69 | 69 | $count = count($items); |
70 | - for ($idx=0; $idx<$count; $idx++) { |
|
70 | + for ($idx = 0; $idx < $count; $idx++) { |
|
71 | 71 | $this->resultSet[] = $items[$idx]; |
72 | 72 | } |
73 | 73 | return $this; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @codeCoverageIgnore |
86 | 86 | * Passing anonymous function to Clusterpoint API |
87 | 87 | */ |
88 | - return function ($collection) use ($conditions, $logical) { |
|
88 | + return function($collection) use ($conditions, $logical) { |
|
89 | 89 | $this->parseWhere($collection, $conditions, $logical); |
90 | 90 | }; |
91 | 91 | } |