Skip to content

Commit aeff311

Browse files
author
Michael Lundbøl
committed
Install and run grumphp
1 parent 20d7df4 commit aeff311

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "^7.0",
21-
"mockery/mockery": "^1.2"
21+
"mockery/mockery": "^1.2",
22+
"phpro/grumphp": "^0.14.3",
23+
"wearejust/grumphp-extra-tasks": "^2.2",
24+
"friendsofphp/php-cs-fixer": "^2.14"
2225
},
2326
"autoload": {
2427
"psr-4": {

src/Client.php

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

33
namespace Napp\Salesforce;
44

5-
use function Couchbase\defaultDecoder;
6-
use Napp\Salesforce\Exceptions\RequestException;
75
use GuzzleHttp\Exception\GuzzleException;
86
use Napp\Salesforce\Exceptions\AuthenticationException;
7+
use Napp\Salesforce\Exceptions\RequestException;
98

109
class Client
1110
{
@@ -129,7 +128,7 @@ public function getRecord(string $objectType, string $id, array $fields = []): a
129128

130129
return $this->makeRequest(
131130
'get',
132-
$this->generateUrl('sobjects/'. $objectType . '/' . $id . $fieldsQuery),
131+
$this->generateUrl('sobjects/' . $objectType . '/' . $id . $fieldsQuery),
133132
[
134133
'headers' => [
135134
'Authorization' => $this->getAuthHeader()
@@ -162,7 +161,7 @@ public function search($query = null, $nextUrl = null): array
162161

163162
$nextRecordsUrl = $data['nextRecordsUrl'] ?? '';
164163

165-
if (! $done) {
164+
if (!$done) {
166165
$moreResults = $this->search(null, substr($nextRecordsUrl, 1));
167166

168167
if ([] !== $moreResults) {
@@ -187,7 +186,7 @@ public function search($query = null, $nextUrl = null): array
187186
*/
188187
public function updateRecord(string $type, string $objectId, array $data): bool
189188
{
190-
$url = $this->generateUrl('sobjects/'. $type . '/' . $objectId);
189+
$url = $this->generateUrl('sobjects/' . $type . '/' . $objectId);
191190

192191
$this->makeRequest('patch', $url, [
193192
'headers' => [
@@ -211,7 +210,7 @@ public function updateRecord(string $type, string $objectId, array $data): bool
211210
*/
212211
public function createRecord(string $type, array $data): string
213212
{
214-
$url = $this->generateUrl('sobjects/'. $type);
213+
$url = $this->generateUrl('sobjects/' . $type);
215214

216215
$response = $this->makeRequest(
217216
'post',
@@ -239,7 +238,7 @@ public function createRecord(string $type, array $data): string
239238
*/
240239
public function deleteRecord(string $type, string $objectId): bool
241240
{
242-
$url = $this->generateUrl('sobjects/'. $type . '/' . $objectId);
241+
$url = $this->generateUrl('sobjects/' . $type . '/' . $objectId);
243242

244243
$this->makeRequest('delete', $url, ['headers' => ['Authorization' => $this->getAuthHeader()]]);
245244

@@ -403,6 +402,6 @@ private function getAuthHeader(): string
403402
*/
404403
private function generateUrl(string $append): string
405404
{
406-
return $this->baseUrl . '/services/data/'.$this->clientConfig->getVersion().'/'.$append;
405+
return $this->baseUrl . '/services/data/' . $this->clientConfig->getVersion() . '/' . $append;
407406
}
408407
}

src/Exceptions/RequestException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function withResponseError($data, Throwable $previous, int $code =
2828
if (isset($data['error'], $data['error_description'])) {
2929
$self->errorCode = $data['error'];
3030
$self->message = $data['error_description'];
31-
} else if (isset($data[0]['message'], $data[0]['errorCode'])) {
31+
} elseif (isset($data[0]['message'], $data[0]['errorCode'])) {
3232
$self->errorCode = $data[0]['errorCode'];
3333
$self->message = $data[0]['message'];
3434
} else {
@@ -43,6 +43,7 @@ public static function withoutResponseError($message, Throwable $previous, int $
4343
{
4444
$self = new self($message, $previous, $code);
4545
$self->errorCode = 500;
46+
4647
return $self;
4748
}
4849

0 commit comments

Comments
 (0)