Skip to content

Commit da59cec

Browse files
authored
Merge pull request #55 from frankkessler/analysis-qBwDYg
Applied fixes from StyleCI
2 parents 37f7ee8 + 1768fcf commit da59cec

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/Bulk.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function runBatch($operation, $objectType, $data, $options = [])
7373
$time = time();
7474
$timeout = $time + $options['batchTimeout'];
7575

76-
if($options['Sforce-Enable-PKChunking']){
76+
if ($options['Sforce-Enable-PKChunking']) {
7777
$batches = $this->allBatchDetails($job->id, $options['contentType']);
7878
}
7979

@@ -89,8 +89,7 @@ public function runBatch($operation, $objectType, $data, $options = [])
8989

9090
$batch = $this->batchDetails($job->id, $batch->id, $options['contentType']);
9191
if (in_array($batch->state, ['Completed', 'Failed', 'Not Processed', 'NotProcessed'])) {
92-
93-
if(in_array($batch->state, ['Completed'])) {
92+
if (in_array($batch->state, ['Completed'])) {
9493
$batchResult = $this->batchResult($job->id, $batch->id, $options['isBatchedResult'], null, $options['contentType']);
9594
$batch->records = $batchResult->records;
9695
}
@@ -126,7 +125,7 @@ public function runBatch($operation, $objectType, $data, $options = [])
126125
*
127126
* @return BulkJobResponse
128127
*/
129-
public function createJob($operation, $objectType, $externalIdFieldName = null, $contentType = 'JSON', $concurrencyMode = 'Parallel', $options=[])
128+
public function createJob($operation, $objectType, $externalIdFieldName = null, $contentType = 'JSON', $concurrencyMode = 'Parallel', $options = [])
130129
{
131130
$url = '/services/async/'.SalesforceConfig::get('salesforce.api.version').'/job';
132131

@@ -138,7 +137,7 @@ public function createJob($operation, $objectType, $externalIdFieldName = null,
138137

139138
$headers = [];
140139

141-
if(isset($options['Sforce-Enable-PKChunking']) && $options['Sforce-Enable-PKChunking']){
140+
if (isset($options['Sforce-Enable-PKChunking']) && $options['Sforce-Enable-PKChunking']) {
142141
$headers['Sforce-Enable-PKChunking'] = $this->parsePkChunkingHeader($options['Sforce-Enable-PKChunking']);
143142
}
144143

@@ -161,7 +160,7 @@ public function createJob($operation, $objectType, $externalIdFieldName = null,
161160
return new BulkJobResponse();
162161
}
163162

164-
public function jobDetails($jobId, $format='json')
163+
public function jobDetails($jobId, $format = 'json')
165164
{
166165
$url = '/services/async/'.SalesforceConfig::get('salesforce.api.version').'/job/'.$jobId;
167166

@@ -209,7 +208,7 @@ public function closeJob($jobId)
209208
*
210209
* @return BulkBatchResponse
211210
*/
212-
public function addBatch($jobId, $data, $format='json')
211+
public function addBatch($jobId, $data, $format = 'json')
213212
{
214213
if (!$jobId) {
215214
//throw exception
@@ -287,7 +286,7 @@ public function allBatchDetails($jobId, $format = 'json')
287286
]);
288287

289288
if ($result && is_array($result) && isset($result['batchInfo']) && !isset($result['batchInfo']['id'])) {
290-
foreach($result['batchInfo'] as $batch) {
289+
foreach ($result['batchInfo'] as $batch) {
291290
$batches[] = new BulkBatchResponse($batch);
292291
}
293292
} else {
@@ -318,7 +317,7 @@ public function batchResult($jobId, $batchId, $isBatchedResult = false, $resultI
318317
if ($resultId) {
319318
$url = $url.'/'.$resultId;
320319
$resultPostArray['format'] = $format;
321-
}else{
320+
} else {
322321
$resultPostArray['format'] = $this->batchResponseFormatFromContentType($format);
323322
}
324323

@@ -331,8 +330,8 @@ public function batchResult($jobId, $batchId, $isBatchedResult = false, $resultI
331330
$result['records'] = [];
332331
}
333332

334-
if(isset($result['result'])){
335-
if(!is_array($result['result'])){
333+
if (isset($result['result'])) {
334+
if (!is_array($result['result'])) {
336335
$result['result'] = [$result['result']];
337336
}
338337
$result = array_merge($result, $result['result']);
@@ -519,16 +518,17 @@ protected function batchResponseFormatFromContentType($contentType)
519518

520519
protected function parsePkChunkingHeader($pk_chunk_header)
521520
{
522-
if(is_array($pk_chunk_header)){
521+
if (is_array($pk_chunk_header)) {
523522
$header_parts = [];
524-
foreach($pk_chunk_header as $key=>$value) {
523+
foreach ($pk_chunk_header as $key => $value) {
525524
$header_parts[] = $key.'='.$value;
526525
}
527526

528-
return implode('; ',$header_parts);
529-
}elseif(in_array($pk_chunk_header, [true,'true','TRUE'])){
527+
return implode('; ', $header_parts);
528+
} elseif (in_array($pk_chunk_header, [true, 'true', 'TRUE'])) {
530529
return 'TRUE';
531530
}
531+
532532
return 'FALSE';
533533
}
534534
}

tests/BulkTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function testRunPkChunkQueryBatch()
209209
new Response(200, [], $this->batchXml()),
210210
new Response(200, [], $this->batchListXml()),
211211
new Response(200, [], $this->batchXml('NotProcessed')),
212-
new Response(200, [], $this->batchXml('Completed','8914000000B5YcIAAV','89040000006iLsVAAU')),
212+
new Response(200, [], $this->batchXml('Completed', '8914000000B5YcIAAV', '89040000006iLsVAAU')),
213213
new Response(200, [], $this->dataQueryResultXml()),
214214
new Response(200, [], $this->dataQueryDataResultCsv()),
215215
new Response(200, [], json_encode($this->jobArray())),
@@ -232,18 +232,18 @@ public function testRunPkChunkQueryBatch()
232232
$query = "SELECT Id, Name FROM Account WHERE RecordTypeId='xxxxxxxxxxxxxx'";
233233

234234
$job = $salesforce->bulk()->runBatch($operation, $objectType, $query, [
235-
'contentType' => 'CSV',
235+
'contentType' => 'CSV',
236236
'Sforce-Enable-PKChunking' => [
237237
'chunkSize' => 2500,
238238
],
239239
]);
240240

241241
$this->assertEquals($jobId, $job->id);
242242

243-
$i=0;
243+
$i = 0;
244244
foreach ($job->batches as $batch) {
245245
//second batch is the one with data
246-
if($i==0){
246+
if ($i == 0) {
247247
$i++;
248248
continue;
249249
}
@@ -476,7 +476,7 @@ public function requestDotTxtContents()
476476
]';
477477
}
478478

479-
public function batchXml($state='Queued', $batchId='89040000006iLsVAAU', $jobId='750D00000004SkVIAU')
479+
public function batchXml($state = 'Queued', $batchId = '89040000006iLsVAAU', $jobId = '750D00000004SkVIAU')
480480
{
481481
return '<?xml version="1.0" encoding="UTF-8"?><batchInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
482482
<id>'.$batchId.'</id>

0 commit comments

Comments
 (0)