Skip to content

Commit 0aa813c

Browse files
committed
Code Qaulity Fixes
1 parent 1a4322c commit 0aa813c

27 files changed

+69
-78
lines changed

Diff for: examples/AuditLog.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
$Account['name'] = 'Audit Log Test - Updated';
2222
$Account['assigned_user_id'] = 'seed_max_id';
2323
$Account->save();
24-
echo "Account Updated: " . json_encode($Account->toArray(),JSON_PRETTY_PRINT) . "\n";
24+
echo "Account Updated: " . json_encode($Account->toArray(), JSON_PRETTY_PRINT) . "\n";
2525
$Account->audit();
26-
echo "Audit Log: " . json_encode($Account->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
26+
echo "Audit Log: " . json_encode($Account->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2727
} else {
2828
echo "Could not login.";
2929
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');
@@ -36,4 +36,4 @@
3636
} catch (Exception $ex) {
3737
echo "Exception Occurred: " . $ex->getMessage();
3838
echo $ex->getTraceAsString();
39-
}
39+
}

Diff for: examples/Bulk.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
try {
1212
if ($SugarAPI->isAuthenticated()) {
13-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
13+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1414

1515
$lead1 = $SugarAPI->module("Leads");
1616
$lead2 = $SugarAPI->module("Leads");
@@ -44,4 +44,4 @@
4444
} catch (Exception $ex) {
4545
echo "Exception Occurred: " . $ex->getMessage();
4646
echo $ex->getTraceAsString();
47-
}
47+
}

Diff for: examples/CRUD.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
try {
1212
if ($SugarAPI->isAuthenticated()) {
13-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
13+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1414
// Create an Account called Test with a phone number
1515
$Account = $SugarAPI->module('Accounts');
1616
// You can set data via Array Access, Object Access, or set methods
@@ -24,15 +24,15 @@
2424
$Account->set('employees', '100');
2525
$Account['shipping_address_city'] = 'Indianapolis';
2626
$Account->save();
27-
echo "Account Updated: " . json_encode($Account->toArray(),JSON_PRETTY_PRINT) . "\n";
27+
echo "Account Updated: " . json_encode($Account->toArray(), JSON_PRETTY_PRINT) . "\n";
2828

2929
//Retrieve the Account in a new Object
3030
$Account2 = $SugarAPI->module('Accounts', $Account['id']);
3131
$Account2->retrieve();
32-
echo "Retrieved Account: " . json_encode($Account2->toArray(),JSON_PRETTY_PRINT) . "\n";
32+
echo "Retrieved Account: " . json_encode($Account2->toArray(), JSON_PRETTY_PRINT) . "\n";
3333
//Delete the Account
3434
$Account2->delete();
35-
echo "Deleted Response: " . json_encode($Account2->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
35+
echo "Deleted Response: " . json_encode($Account2->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
3636
} else {
3737
echo "Could not login.";
3838
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/DuplicateCheck.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
try {
1212
if ($SugarAPI->isAuthenticated()) {
13-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
13+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1414
//Create a new Account
1515
$Account = $SugarAPI->module('Accounts')->set("name", "DuplicateCheck Test");
1616
$Account->save();
1717
echo "Account Created: {$Account['id']}\n";
1818
// Run duplicate check
1919
$Account->duplicateCheck();
20-
echo "Response: " . json_encode($Account->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
20+
echo "Response: " . json_encode($Account->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2121
} else {
2222
echo "Could not login.";
2323
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/Favorite.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
try {
1212
if ($SugarAPI->isAuthenticated()) {
13-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
13+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1414
//Create a new Account
1515
$Account = $SugarAPI->module('Accounts')->set("name", "Favorite Test");
1616
$Account->save();
@@ -29,4 +29,4 @@
2929
} catch (Exception $ex) {
3030
echo "Exception Occurred: " . $ex->getMessage();
3131
echo $ex->getTraceAsString();
32-
}
32+
}

Diff for: examples/FileManipulation.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
$SugarAPI = new \Sugarcrm\REST\Client\SugarAPI($server, $credentials);
1414
try {
1515
if ($SugarAPI->isAuthenticated()) {
16-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
16+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1717

1818
$Note = $SugarAPI->module('Notes')->set("name", "Test");
1919
//Create a note with subject
2020
$Note->save();
2121
echo "Saved Note ID: {$Note['id']}<br>";
2222
echo "Attempting to attach $file...";
2323
$Note->attachFile('filename', $file, true, 'testtest.txt');
24-
echo "File uploaded: " . json_encode($Note->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
24+
echo "File uploaded: " . json_encode($Note->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2525

2626
$Note = $SugarAPI->module('Notes');
2727
echo "Uploading temp file for new note...";
2828
$Note->tempFile('filename', $file);
29-
echo "Temp File uploaded: " . json_encode($Note->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
29+
echo "Temp File uploaded: " . json_encode($Note->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
3030
$Note->set('name', 'This is a test');
3131
$Note->save();
3232
echo "Note ID: {$Note['id']}\n";

Diff for: examples/FilterAPI.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$SugarAPI = new \Sugarcrm\REST\Client\SugarApi($server, $credentials);
1010
try {
1111
if ($SugarAPI->isAuthenticated()) {
12-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
12+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1313

1414
$Accounts = $SugarAPI->list('Accounts');
1515
$Accounts->filter()->and()
@@ -40,7 +40,7 @@
4040
->endDate()
4141
->endOr();
4242
echo "Filtering Accounts that are created between dates, or in the last 7 days: "
43-
. json_encode($Accounts->filter()->compile(),JSON_PRETTY_PRINT) . "\n";
43+
. json_encode($Accounts->filter()->compile(), JSON_PRETTY_PRINT) . "\n";
4444
$Accounts->fetch();
4545
echo "Accounts: " . json_encode($Accounts->toArray(), JSON_PRETTY_PRINT) . "\n";
4646
} else {

Diff for: examples/FilterRelated.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
$SugarAPI = new \Sugarcrm\REST\Client\SugarApi($server, $credentials);
1010
try {
1111
if ($SugarAPI->isAuthenticated()) {
12-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
12+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1313
$Accounts = $SugarAPI->list('Accounts');
1414
$Accounts->fetch();
1515
//Get first Account in Collection
1616
$Account = $Accounts->at(1);
1717
//Execute Related contacts count API call
1818
$Account->getRelated('contacts', true);
19-
echo "Related Contacts Count response: " . json_encode($Account->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
19+
echo "Related Contacts Count response: " . json_encode($Account->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2020
//Assuming there are >0 related contacts, filter them by first name contain an `s`
2121
$Filter = $Account->filterRelated('contacts')->contains('first_name', 's');
22-
echo "Filter Def for API: " . json_encode($Filter->compile(),JSON_PRETTY_PRINT) . "\n";
22+
echo "Filter Def for API: " . json_encode($Filter->compile(), JSON_PRETTY_PRINT) . "\n";
2323
$Filter->execute();
24-
echo "Response:" . json_encode($Account->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
24+
echo "Response:" . json_encode($Account->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2525
} else {
2626
echo "Could not login.";
2727
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/ModuleEnum.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
try {
1111
if ($SugarAPI->isAuthenticated()) {
12-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
12+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1313

1414
$Enum = $SugarAPI->enum('Accounts', 'account_type')->execute();
15-
echo "Account Type options: " . json_encode($Enum->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
15+
echo "Account Type options: " . json_encode($Enum->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
1616
} else {
1717
echo "Could not login.";
1818
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/NoteAttachments.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$SugarAPI = new \Sugarcrm\REST\Client\SugarAPI($server, $credentials);
1414
try {
1515
if ($SugarAPI->isAuthenticated()) {
16-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
16+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1717

1818
$Note = $SugarAPI->note()->set("name", "Test");
1919
echo "Creating Note with multiple attachments: ";
@@ -34,7 +34,7 @@
3434
//Add attachment_list field to retrieve request so we can see uploaded files
3535
$Note->addField('attachment_list');
3636
$Note->retrieve();
37-
echo "Attachments: " . json_encode($Note->attachment_list,JSON_PRETTY_PRINT) . "\n";
37+
echo "Attachments: " . json_encode($Note->attachment_list, JSON_PRETTY_PRINT) . "\n";
3838
} else {
3939
echo "Could not login.";
4040
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/RelateRecords.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
$SugarAPI = new \Sugarcrm\REST\Client\SugarApi($server, $credentials);
1010
try {
1111
if ($SugarAPI->isAuthenticated()) {
12-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
12+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1313
$Account = $SugarAPI->module('Accounts')->set("name", "Relate Records Test");
1414
$Account->save();
15-
echo "Created Account {$Account['id']}: " . json_encode($Account->toArray(),JSON_PRETTY_PRINT) . "\n";
15+
echo "Created Account {$Account['id']}: " . json_encode($Account->toArray(), JSON_PRETTY_PRINT) . "\n";
1616

1717
$Opportunity = $SugarAPI->module('Opportunities');
1818
$Opportunity['name'] = 'Test Opportunity';
1919
$Opportunity['description'] = 'This opportunity was created via the SugarCRM PHP REST Client v1 to test creating relationships.';
2020
$Opportunity->save();
21-
echo "Created Opportunity {$Opportunity['id']}: " . json_encode($Opportunity->toArray(),JSON_PRETTY_PRINT) . "\n";
21+
echo "Created Opportunity {$Opportunity['id']}: " . json_encode($Opportunity->toArray(), JSON_PRETTY_PRINT) . "\n";
2222

2323
echo "Relating Opportunity to Account: ";
2424
$Account->relate('opportunities', $Opportunity['id']);
25-
echo "Response: " . json_encode($Account->getResponseBody(),JSON_PRETTY_PRINT) . "\n";
25+
echo "Response: " . json_encode($Account->getResponseBody(), JSON_PRETTY_PRINT) . "\n";
2626
} else {
2727
echo "Could not login.";
2828
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');

Diff for: examples/Sudo.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
$SugarAPI = new \Sugarcrm\REST\Client\SugarApi($server, $credentials);
1010
try {
1111
if ($SugarAPI->isAuthenticated()) {
12-
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
12+
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1313
if ($SugarAPI->sudo('will')) {
14-
echo "Sudo'd to will. Token: " . json_encode($SugarAPI->getAuth()->getToken(),JSON_PRETTY_PRINT) . "\n";
14+
echo "Sudo'd to will. Token: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
1515
$Me = $SugarAPI->me();
1616
$Me->retrieve();
17-
echo "User: " . json_encode($Me->toArray(),JSON_PRETTY_PRINT) . "\n";
17+
echo "User: " . json_encode($Me->toArray(), JSON_PRETTY_PRINT) . "\n";
1818
}
1919
} else {
2020
echo "Could not login.";

Diff for: examples/include.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
require_once __DIR__ . '/../vendor/autoload.php';
88

99
$server = 'localhost';
10-
$credentials = array(
10+
$credentials = [
1111
'username' => 'admin',
1212
'password' => 'asdf',
13-
'platform' => 'base'
14-
);
13+
'platform' => 'base',
14+
];

Diff for: src/Auth/SugarOAuthController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function generateUniqueCacheString(array $creds): string
8181
$key = '';
8282
try {
8383
$ep = $this->getActionEndpoint(self::ACTION_AUTH);
84-
$key = preg_replace("/\/rest\/v[^\/]+\//","",$ep->getBaseUrl());
84+
$key = preg_replace("/\/rest\/v[^\/]+\//", "", $ep->getBaseUrl());
8585
} catch (\Exception) {
8686
$this->getLogger()->info("Cannot use server in cache string.");
8787
}

Diff for: src/Endpoint/Abstracts/AbstractSugarBeanEndpoint.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ abstract class AbstractSugarBeanEndpoint extends ModelEndpoint implements SugarE
9494
protected static array $_DEFAULT_PROPERTIES = [
9595
self::PROPERTY_URL => '$module/$id/$:action/$:actionArg1/$:actionArg2/$:actionArg3',
9696
self::PROPERTY_HTTP_METHOD => 'GET',
97-
self::PROPERTY_AUTH => true
97+
self::PROPERTY_AUTH => true,
9898
];
9999

100100
/**
@@ -380,7 +380,7 @@ public function relate(string $linkName, string $related_id): static
380380
*/
381381
public function auditLog(?int $limit = null): AuditLog
382382
{
383-
$auditCollection = new AuditLog([],['module' => $this->getModule(), 'id' => $this->get('id')]);
383+
$auditCollection = new AuditLog([], ['module' => $this->getModule(), 'id' => $this->get('id')]);
384384

385385
if ($limit !== null) {
386386
$auditCollection->setLimit($limit);

Diff for: src/Endpoint/AuditLog.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class AuditLog extends SugarBeanCollection
88
self::PROPERTY_URL => '$module/$id/audit',
99
self::PROPERTY_AUTH => true,
1010
];
11-
}
11+
}

Diff for: src/Endpoint/Collection.php

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

55
use Sugarcrm\REST\Endpoint\Abstracts\AbstractSugarCollectionEndpoint;
66

7-
class Collection extends AbstractSugarCollectionEndpoint
8-
{
9-
}
7+
class Collection extends AbstractSugarCollectionEndpoint {}

Diff for: src/Endpoint/Email.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function addAttachments(array $files, bool $async = true): self
4242
if ($async) {
4343
$responses = Utils::unwrap($promises);
4444
$Note = new Note();
45-
foreach($responses as $response){
45+
foreach ($responses as $response) {
4646
$Note->setResponse($response);
4747
$this->parseAttachmentUploadResponse($Note->getResponseBody());
4848
}
@@ -51,4 +51,4 @@ public function addAttachments(array $files, bool $async = true): self
5151

5252
return $this;
5353
}
54-
}
54+
}

Diff for: src/Endpoint/Generic.php

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

55
use Sugarcrm\REST\Endpoint\Abstracts\AbstractSugarEndpoint;
66

7-
class Generic extends AbstractSugarEndpoint
8-
{
9-
}
7+
class Generic extends AbstractSugarEndpoint {}

Diff for: src/Endpoint/MLPackage.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MLPackage extends SugarBean
3030
self::ACTION_ENABLE => 'GET',
3131
self::ACTION_DISABLE => 'GET',
3232
self::ACTION_INSTALL_STATUS => 'GET',
33-
self::BEAN_ACTION_ATTACH_FILE => 'POST'
33+
self::BEAN_ACTION_ATTACH_FILE => 'POST',
3434
];
3535

3636
protected bool $_installing = false;
@@ -99,7 +99,7 @@ protected function parseResponse(Response $response): void
9999
$this->_installing = false;
100100
break;
101101
case self::ACTION_INSTALL_STATUS:
102-
if (!empty($data['message'])){
102+
if (!empty($data['message'])) {
103103
$this->_installOutput = $data['message'] ?? [];
104104
}
105105
break;
@@ -118,4 +118,4 @@ protected function configureFileUploadQueryParams(): array
118118
{
119119
return [];
120120
}
121-
}
121+
}

Diff for: src/Endpoint/ModuleLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ModuleLoader extends CollectionEndpoint
1616
self::PROPERTY_URL => 'Administration/packages/$:filter',
1717
self::PROPERTY_RESPONSE_PROP => 'packages',
1818
self::PROPERTY_HTTP_METHOD => 'GET',
19-
self::PROPERTY_AUTH => true
19+
self::PROPERTY_AUTH => true,
2020
];
2121

2222
protected string $_modelInterface = MLPackage::class;
@@ -67,4 +67,4 @@ public function newPackage(): MLPackage
6767
{
6868
return $this->generateEndpoint(MLPackage::class);
6969
}
70-
}
70+
}

Diff for: src/Endpoint/Provider/SugarEndpointProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SugarEndpointProvider extends VersionedEndpointProvider
8989
self::ENDPOINT_PROPERTIES => [
9090
Generic::PROPERTY_URL => 'oauth2/logout',
9191
Generic::PROPERTY_AUTH => true,
92-
Generic::PROPERTY_HTTP_METHOD => "POST"
92+
Generic::PROPERTY_HTTP_METHOD => "POST",
9393
],
9494
],
9595
[
@@ -154,6 +154,6 @@ class SugarEndpointProvider extends VersionedEndpointProvider
154154
self::ENDPOINT_NAME => 'mlp',
155155
self::ENDPOINT_CLASS => MLPackage::class,
156156
self::ENDPOINT_PROPERTIES => [],
157-
]
157+
],
158158
];
159159
}

Diff for: src/Endpoint/Smart.php

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

55
use Sugarcrm\REST\Endpoint\Abstracts\AbstractSmartSugarEndpoint;
66

7-
class Smart extends AbstractSmartSugarEndpoint
8-
{
9-
}
7+
class Smart extends AbstractSmartSugarEndpoint {}

Diff for: src/Endpoint/SugarBeanCollection.php

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

55
use Sugarcrm\REST\Endpoint\Abstracts\AbstractSugarBeanCollectionEndpoint;
66

7-
class SugarBeanCollection extends AbstractSugarBeanCollectionEndpoint
8-
{
9-
10-
}
7+
class SugarBeanCollection extends AbstractSugarBeanCollectionEndpoint {}

Diff for: tests/Endpoint/Data/BulkRequestTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testAsArray(): void
6969

7070
$Request = new Request("POST", 'http://localhost/rest/v11/Accounts', ['Content-Type' => 'application/json'], json_encode(['foo' => 'bar']));
7171

72-
$Filter = new ModuleFilter([],['Contacts']);
72+
$Filter = new ModuleFilter([], ['Contacts']);
7373
$Filter->setBaseUrl('http://localhost/rest/v11');
7474
$Filter->filter()->equals('foo', 'bar');
7575

0 commit comments

Comments
 (0)