Skip to content

Commit e20a69a

Browse files
ismaildascigithub-actions[bot]
authored andcommitted
Fix styling
1 parent 654958a commit e20a69a

4 files changed

Lines changed: 44 additions & 42 deletions

File tree

examples/BasicUsage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
],
8585
]);
8686

87-
echo "Created order with DocEntry: " . $order['DocEntry'] . PHP_EOL;
87+
echo 'Created order with DocEntry: '.$order['DocEntry'].PHP_EOL;
8888

8989
// =============================================================================
9090
// UPDATING RECORDS
@@ -134,10 +134,10 @@
134134
$partners = $response->value();
135135
$count = $response->count();
136136

137-
echo "Found {$count} partners" . PHP_EOL;
137+
echo "Found {$count} partners".PHP_EOL;
138138

139139
foreach ($partners as $partner) {
140-
echo "- {$partner['CardCode']}: {$partner['CardName']}" . PHP_EOL;
140+
echo "- {$partner['CardCode']}: {$partner['CardName']}".PHP_EOL;
141141
}
142142
}
143143

examples/BatchOperations.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
// Process responses
2929
foreach ($responses as $index => $response) {
3030
if ($response->successful()) {
31-
echo "Request {$index}: Success" . PHP_EOL;
31+
echo "Request {$index}: Success".PHP_EOL;
3232
print_r($response->value());
3333
} else {
34-
echo "Request {$index}: Failed - " . $response->status() . PHP_EOL;
34+
echo "Request {$index}: Failed - ".$response->status().PHP_EOL;
3535
}
3636
}
3737

@@ -123,14 +123,14 @@
123123
// Check for errors
124124
$hasErrors = false;
125125
foreach ($responses as $response) {
126-
if (!$response->successful()) {
126+
if (! $response->successful()) {
127127
$hasErrors = true;
128-
echo "Error: " . $response->json()['error']['message']['value'] ?? 'Unknown error' . PHP_EOL;
128+
echo 'Error: '.$response->json()['error']['message']['value'] ?? 'Unknown error'.PHP_EOL;
129129
}
130130
}
131131

132-
if (!$hasErrors) {
133-
echo "All items updated successfully!" . PHP_EOL;
132+
if (! $hasErrors) {
133+
echo 'All items updated successfully!'.PHP_EOL;
134134
}
135135

136136
// =============================================================================
@@ -160,10 +160,10 @@
160160

161161
try {
162162
$responses = $batch->execute();
163-
echo "Imported " . count($partnersToImport) . " partners successfully!" . PHP_EOL;
163+
echo 'Imported '.count($partnersToImport).' partners successfully!'.PHP_EOL;
164164
} catch (\SapB1\Exceptions\ServiceLayerException $e) {
165-
echo "Import failed: " . $e->getHumanMessage() . PHP_EOL;
166-
echo "Suggestion: " . $e->getSuggestion() . PHP_EOL;
165+
echo 'Import failed: '.$e->getHumanMessage().PHP_EOL;
166+
echo 'Suggestion: '.$e->getSuggestion().PHP_EOL;
167167
}
168168

169169
// =============================================================================

examples/ErrorHandling.php

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,58 +31,58 @@
3131
]);
3232
} catch (AuthenticationException $e) {
3333
// Invalid credentials or login failed
34-
echo "Authentication failed: " . $e->getMessage() . PHP_EOL;
34+
echo 'Authentication failed: '.$e->getMessage().PHP_EOL;
3535
// Suggestion: Check SAP_B1_USERNAME and SAP_B1_PASSWORD in .env
3636

3737
} catch (SessionExpiredException $e) {
3838
// Session timed out (usually auto-refreshed, but can occur)
39-
echo "Session expired: " . $e->getMessage() . PHP_EOL;
39+
echo 'Session expired: '.$e->getMessage().PHP_EOL;
4040
// SDK will automatically retry with a new session if auto_refresh is enabled
4141

4242
} catch (RateLimitException $e) {
4343
// Too many requests (429)
44-
echo "Rate limited! Retry after: " . $e->getRetryAfter() . " seconds" . PHP_EOL;
44+
echo 'Rate limited! Retry after: '.$e->getRetryAfter().' seconds'.PHP_EOL;
4545
sleep($e->getRetryAfter());
4646
// Retry the request...
4747

4848
} catch (CircuitBreakerOpenException $e) {
4949
// Circuit breaker is open due to repeated failures
50-
echo "Service temporarily unavailable (circuit open)" . PHP_EOL;
51-
echo "Will recover after: " . $e->getRecoveryTime()->diffForHumans() . PHP_EOL;
50+
echo 'Service temporarily unavailable (circuit open)'.PHP_EOL;
51+
echo 'Will recover after: '.$e->getRecoveryTime()->diffForHumans().PHP_EOL;
5252
// Don't retry immediately - the circuit breaker protects the server
5353

5454
} catch (PoolExhaustedException $e) {
5555
// No sessions available in pool (high concurrency scenario)
56-
echo "No sessions available, try again later" . PHP_EOL;
56+
echo 'No sessions available, try again later'.PHP_EOL;
5757
// Consider increasing pool size or wait_timeout in config
5858

5959
} catch (ProxyException $e) {
6060
// Proxy/gateway error (502)
61-
echo "Proxy error: " . $e->getMessage() . PHP_EOL;
61+
echo 'Proxy error: '.$e->getMessage().PHP_EOL;
6262
// Usually temporary - SDK will retry automatically
6363

6464
} catch (ConnectionException $e) {
6565
// Network connectivity issues
66-
echo "Cannot connect to SAP server: " . $e->getMessage() . PHP_EOL;
66+
echo 'Cannot connect to SAP server: '.$e->getMessage().PHP_EOL;
6767
// Check network, firewall, VPN, or SAP server status
6868

6969
} catch (ServiceLayerException $e) {
7070
// SAP Business logic error
71-
echo "SAP Error Code: " . $e->getCode() . PHP_EOL;
72-
echo "SAP Message: " . $e->getMessage() . PHP_EOL;
73-
echo "Human Message: " . $e->getHumanMessage() . PHP_EOL;
74-
echo "Suggestion: " . $e->getSuggestion() . PHP_EOL;
75-
echo "Category: " . $e->getCategory() . PHP_EOL;
76-
echo "Is Retryable: " . ($e->isRetryable() ? 'Yes' : 'No') . PHP_EOL;
71+
echo 'SAP Error Code: '.$e->getCode().PHP_EOL;
72+
echo 'SAP Message: '.$e->getMessage().PHP_EOL;
73+
echo 'Human Message: '.$e->getHumanMessage().PHP_EOL;
74+
echo 'Suggestion: '.$e->getSuggestion().PHP_EOL;
75+
echo 'Category: '.$e->getCategory().PHP_EOL;
76+
echo 'Is Retryable: '.($e->isRetryable() ? 'Yes' : 'No').PHP_EOL;
7777

7878
} catch (JsonDecodeException $e) {
7979
// Malformed JSON response
80-
echo "Invalid JSON response: " . $e->getMessage() . PHP_EOL;
81-
echo "Body preview: " . $e->getBodyPreview() . PHP_EOL;
80+
echo 'Invalid JSON response: '.$e->getMessage().PHP_EOL;
81+
echo 'Body preview: '.$e->getBodyPreview().PHP_EOL;
8282

8383
} catch (\Throwable $e) {
8484
// Catch-all for unexpected errors
85-
echo "Unexpected error: " . $e->getMessage() . PHP_EOL;
85+
echo 'Unexpected error: '.$e->getMessage().PHP_EOL;
8686
}
8787

8888
// =============================================================================
@@ -97,7 +97,7 @@
9797
]);
9898
} catch (ServiceLayerException $e) {
9999
if ($e->getCode() === -2035) {
100-
echo "Business partner already exists, updating instead..." . PHP_EOL;
100+
echo 'Business partner already exists, updating instead...'.PHP_EOL;
101101
SapB1::update('BusinessPartners', 'EXISTING_CODE', [
102102
'CardName' => 'Test',
103103
]);
@@ -111,7 +111,7 @@
111111
SapB1::update('BusinessPartners', 'NONEXISTENT', ['CardName' => 'New Name']);
112112
} catch (ServiceLayerException $e) {
113113
if ($e->getCode() === -2028) {
114-
echo "Business partner not found: NONEXISTENT" . PHP_EOL;
114+
echo 'Business partner not found: NONEXISTENT'.PHP_EOL;
115115
} else {
116116
throw $e;
117117
}
@@ -122,8 +122,8 @@
122122
SapB1::delete('BusinessPartners', 'C001');
123123
} catch (ServiceLayerException $e) {
124124
if ($e->getCategory() === 'constraint_violation') {
125-
echo "Cannot delete: " . $e->getHumanMessage() . PHP_EOL;
126-
echo "Tip: " . $e->getSuggestion() . PHP_EOL;
125+
echo 'Cannot delete: '.$e->getHumanMessage().PHP_EOL;
126+
echo 'Tip: '.$e->getSuggestion().PHP_EOL;
127127
} else {
128128
throw $e;
129129
}
@@ -139,17 +139,17 @@ function createBusinessPartner(array $data): array
139139
$required = ['CardCode', 'CardName', 'CardType'];
140140
$missing = array_diff($required, array_keys($data));
141141

142-
if (!empty($missing)) {
142+
if (! empty($missing)) {
143143
throw new \InvalidArgumentException(
144-
'Missing required fields: ' . implode(', ', $missing)
144+
'Missing required fields: '.implode(', ', $missing)
145145
);
146146
}
147147

148148
// Validate CardType
149149
$validTypes = ['cCustomer', 'cSupplier', 'cLead'];
150-
if (!in_array($data['CardType'], $validTypes, true)) {
150+
if (! in_array($data['CardType'], $validTypes, true)) {
151151
throw new \InvalidArgumentException(
152-
'Invalid CardType. Must be one of: ' . implode(', ', $validTypes)
152+
'Invalid CardType. Must be one of: '.implode(', ', $validTypes)
153153
);
154154
}
155155

@@ -171,14 +171,14 @@ function withRetry(callable $operation, int $maxAttempts = 3): mixed
171171
} catch (ServiceLayerException $e) {
172172
$lastException = $e;
173173

174-
if (!$e->isRetryable()) {
174+
if (! $e->isRetryable()) {
175175
throw $e; // Don't retry non-retryable errors
176176
}
177177

178178
$attempt++;
179179
if ($attempt < $maxAttempts) {
180180
$delay = pow(2, $attempt); // Exponential backoff
181-
echo "Attempt {$attempt} failed, retrying in {$delay}s..." . PHP_EOL;
181+
echo "Attempt {$attempt} failed, retrying in {$delay}s...".PHP_EOL;
182182
sleep($delay);
183183
}
184184
}
@@ -226,11 +226,13 @@ function getBusinessPartnersWithFallback(): array
226226
try {
227227
$partners = SapB1::get('BusinessPartners')->value();
228228
cache()->put('business_partners', $partners, 3600);
229+
229230
return $partners;
230231
} catch (ConnectionException|CircuitBreakerOpenException $e) {
231232
$cached = cache()->get('business_partners');
232233
if ($cached !== null) {
233-
Log::warning('Using cached business partners due to: ' . $e->getMessage());
234+
Log::warning('Using cached business partners due to: '.$e->getMessage());
235+
234236
return $cached;
235237
}
236238
throw $e;

examples/QueryExamples.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@
230230
->inlineCount()
231231
->get('Orders');
232232

233-
echo "Found {$orders->count()} orders" . PHP_EOL;
233+
echo "Found {$orders->count()} orders".PHP_EOL;
234234

235235
foreach ($orders->value() as $order) {
236-
echo "{$order['DocNum']}: {$order['CardName']} - \${$order['DocTotal']}" . PHP_EOL;
236+
echo "{$order['DocNum']}: {$order['CardName']} - \${$order['DocTotal']}".PHP_EOL;
237237
}
238238

239239
// =============================================================================

0 commit comments

Comments
 (0)