Skip to content

Commit 6d10f73

Browse files
committed
Merge remote-tracking branch 'origin/master'
Conflicts: src/Bulk.php
2 parents 0cd5e3f + da59cec commit 6d10f73

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/Bulk.php

Lines changed: 14 additions & 14 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 {
@@ -335,8 +334,8 @@ public function batchResult($jobId, $batchId, $isBatchedResult = false, $resultI
335334
$result['records'] = [];
336335
}
337336

338-
if(isset($result['result'])){
339-
if(!is_array($result['result'])){
337+
if (isset($result['result'])) {
338+
if (!is_array($result['result'])) {
340339
$result['result'] = [$result['result']];
341340
}
342341
$result = array_merge($result, $result['result']);
@@ -523,16 +522,17 @@ protected function batchResponseFormatFromContentType($contentType)
523522

524523
protected function parsePkChunkingHeader($pk_chunk_header)
525524
{
526-
if(is_array($pk_chunk_header)){
525+
if (is_array($pk_chunk_header)) {
527526
$header_parts = [];
528-
foreach($pk_chunk_header as $key=>$value) {
527+
foreach ($pk_chunk_header as $key => $value) {
529528
$header_parts[] = $key.'='.$value;
530529
}
531530

532-
return implode('; ',$header_parts);
533-
}elseif(in_array($pk_chunk_header, [true,'true','TRUE'])){
531+
return implode('; ', $header_parts);
532+
} elseif (in_array($pk_chunk_header, [true, 'true', 'TRUE'])) {
534533
return 'TRUE';
535534
}
535+
536536
return 'FALSE';
537537
}
538538
}

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)