Skip to content

Commit

Permalink
Remove else statements and 1 line if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Jan 23, 2024
1 parent 1ffc507 commit a1e183c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions api/src/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,13 @@ public function getSingleFromSource(Synchronization $synchronization): ?array

$url = \Safe\parse_url($synchronization->getSource()->getLocation());

$endpoint = $synchronization->getEndpoint().'/'.$synchronization->getSourceId();
if (str_contains('http', $synchronization->getSourceId()) === true) {
$endpoint = $synchronization->getEndpoint();
}
if (isset($this->configuration['location']) === true) {
$endpoint = $this->configuration['location'];
$synchronization->setEndpoint($endpoint);
} else {
$normalEndpoint = $synchronization->getEndpoint().'/'.$synchronization->getSourceId();
$endpoint = str_contains('http', $synchronization->getSourceId()) === true ? $synchronization->getEndpoint() : $normalEndpoint;
}

if ($url['scheme'] === 'http' || $url['scheme'] === 'https') {
Expand Down Expand Up @@ -1349,12 +1350,16 @@ private function syncToSource(Synchronization $synchronization, bool $existsInSo
$callServiceConfig = $this->getCallServiceConfig($synchronization->getSource(), $existsInSource ? $synchronization->getSourceId() : null, $objectArray);
$objectArray = $this->mapOutput($objectArray);

$endpoint = $synchronization->getEndpoint();
if ($existsInSource === true) {
$endpoint = $endpoint.'/'.$synchronization->getSourceId();
}
if (str_contains('http', $synchronization->getSourceId()) === true) {
$endpoint = $synchronization->getEndpoint();
}
if (isset($this->configuration['location']) === true) {
$endpoint = $this->configuration['location'];
$synchronization->setEndpoint($endpoint);
} else {
$normalEndpoint = $synchronization->getEndpoint().($existsInSource ? '/'.$synchronization->getSourceId() : '');
$endpoint = str_contains('http', $synchronization->getSourceId()) === true ? $synchronization->getEndpoint() : $normalEndpoint;
}

$objectString = $this->getObjectString($objectArray);
Expand Down

0 comments on commit a1e183c

Please sign in to comment.