@@ -9,8 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace Chapi\Service\JobValidator; |
| 11 | 11 | |
| 12 | -use Chapi\Component\DatePeriod\DatePeriodFactoryInterface; |
|
| 13 | -use Chapi\Entity\Chronos\JobEntity; |
|
| 14 | 12 | use Chapi\Entity\JobEntityInterface; |
| 15 | 13 | use Chapi\Entity\JobValidator\ValidationResult; |
| 16 | 14 | |
@@ -148,7 +148,8 @@ |
||
| 148 | 148 | // handle job update |
| 149 | 149 | if ($this->jobComparisonBusinessCase->hasSameJobType($jobEntityLocal, $jobEntityChronos)) { |
| 150 | 150 | $hasUpdatedJob = $this->jobRepositoryRemote->updateJob($jobEntityLocal); |
| 151 | - } else { |
|
| 151 | + } |
|
| 152 | + else { |
|
| 152 | 153 | $hasUpdatedJob = ( |
| 153 | 154 | $this->jobRepositoryRemote->removeJob($jobEntityChronos->getKey()) |
| 154 | 155 | && $this->jobRepositoryRemote->addJob($jobEntityLocal) |
@@ -49,7 +49,8 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | if (empty($entityNames)) { |
| 51 | 51 | $remoteEntities = $this->jobRepositoryRemote->getJobs(); |
| 52 | - } else { |
|
| 52 | + } |
|
| 53 | + else { |
|
| 53 | 54 | $remoteEntities = []; |
| 54 | 55 | foreach ($entityNames as $jobName) { |
| 55 | 56 | $remoteEntities[] = $this->jobRepositoryRemote->getJob($jobName); |
@@ -62,7 +63,8 @@ discard block |
||
| 62 | 63 | // new job |
| 63 | 64 | if (null == $localEntity) { |
| 64 | 65 | $this->addJobInLocalRepository($remoteEntity); |
| 65 | - } else { |
|
| 66 | + } |
|
| 67 | + else { |
|
| 66 | 68 | //update |
| 67 | 69 | $this->updateJobInLocalRepository($remoteEntity, $forceOverwrite); |
| 68 | 70 | } |
@@ -76,7 +78,8 @@ discard block |
||
| 76 | 78 | 'Entity %s stored in local repository', |
| 77 | 79 | $appRemote->getKey() |
| 78 | 80 | )); |
| 79 | - } else { |
|
| 81 | + } |
|
| 82 | + else { |
|
| 80 | 83 | $this->logger->error(sprintf( |
| 81 | 84 | 'Failed to store %s in local repository', |
| 82 | 85 | $appRemote->getKey() |
@@ -103,7 +106,8 @@ discard block |
||
| 103 | 106 | 'Entity %s is updated in local repository', |
| 104 | 107 | $appRemote->getKey() |
| 105 | 108 | )); |
| 106 | - } else { |
|
| 109 | + } |
|
| 110 | + else { |
|
| 107 | 111 | $this->logger->error(sprintf( |
| 108 | 112 | 'Failed to update app %s in local repository', |
| 109 | 113 | $appRemote->getKey() |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - protected function preCompareModifications(JobEntityInterface &$localJob, JobEntityInterface &$remoteJob) |
|
| 56 | + protected function preCompareModifications(JobEntityInterface & $localJob, JobEntityInterface & $remoteJob) |
|
| 57 | 57 | { |
| 58 | 58 | // no modification needed |
| 59 | 59 | return; |
@@ -219,7 +219,8 @@ |
||
| 219 | 219 | if (!empty($timeZone)) { |
| 220 | 220 | $dateTime = new \DateTime(str_replace('Z', '', $iso8601Entity->startTime)); |
| 221 | 221 | $dateTime->setTimezone(new \DateTimeZone($timeZone)); |
| 222 | - } else { |
|
| 222 | + } |
|
| 223 | + else { |
|
| 223 | 224 | $dateTime = new \DateTime($iso8601Entity->startTime); |
| 224 | 225 | } |
| 225 | 226 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $this->diffCompare = $diffCompare; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - protected function preCompareModifications(JobEntityInterface &$localJob, JobEntityInterface &$remoteJob) |
|
| 36 | + protected function preCompareModifications(JobEntityInterface & $localJob, JobEntityInterface & $remoteJob) |
|
| 37 | 37 | { |
| 38 | 38 | if (!$localJob instanceof MarathonAppEntity || |
| 39 | 39 | !$remoteJob instanceof MarathonAppEntity |
@@ -94,9 +94,11 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | if (is_array($valueA) && is_array($valueB)) { |
| 96 | 96 | return $this->isArrayEqual($valueA, $valueB); |
| 97 | - } elseif (is_object($valueA) && is_object($valueB)) { |
|
| 97 | + } |
|
| 98 | + elseif (is_object($valueA) && is_object($valueB)) { |
|
| 98 | 99 | return $this->isArrayEqual(get_object_vars($valueA), get_object_vars($valueB)); |
| 99 | - } elseif ((is_scalar($valueA) && is_scalar($valueB)) || (is_null($valueA) && is_null($valueB))) { |
|
| 100 | + } |
|
| 101 | + elseif ((is_scalar($valueA) && is_scalar($valueB)) || (is_null($valueA) && is_null($valueB))) { |
|
| 100 | 102 | return $valueA == $valueB; |
| 101 | 103 | } |
| 102 | 104 | |
@@ -125,7 +127,8 @@ discard block |
||
| 125 | 127 | if (!array_key_exists($keyA, $valuesB) || !$this->isEqual($valueA, $valuesB[$keyA])) { |
| 126 | 128 | return false; |
| 127 | 129 | } |
| 128 | - } else { |
|
| 130 | + } |
|
| 131 | + else { |
|
| 129 | 132 | foreach ($valuesB as $valueB) { |
| 130 | 133 | if ($this->isEqual($valueA, $valueB)) { |
| 131 | 134 | continue 2; |
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | * @param JobEntityInterface $remoteJob |
| 208 | 208 | * @return null |
| 209 | 209 | */ |
| 210 | - abstract protected function preCompareModifications(JobEntityInterface &$localJob, JobEntityInterface &$remoteJob); |
|
| 210 | + abstract protected function preCompareModifications(JobEntityInterface & $localJob, JobEntityInterface & $remoteJob); |
|
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | 213 | * Gets entity for each system with defaults set |
@@ -149,7 +149,8 @@ discard block |
||
| 149 | 149 | DIRECTORY_SEPARATOR, |
| 150 | 150 | $jobEntity->getKey() |
| 151 | 151 | ); |
| 152 | - } else { |
|
| 152 | + } |
|
| 153 | + else { |
|
| 153 | 154 | $jobPath = $jobEntity->getKey(); |
| 154 | 155 | } |
| 155 | 156 | |
@@ -172,7 +173,8 @@ discard block |
||
| 172 | 173 | foreach ($temp as $path) { |
| 173 | 174 | if (is_file($path) && preg_match('~\.json~i', $path)) { |
| 174 | 175 | $jobFiles[] = $path; |
| 175 | - } elseif (is_dir($path)) { |
|
| 176 | + } |
|
| 177 | + elseif (is_dir($path)) { |
|
| 176 | 178 | $this->getJobFilesFromFileSystem($path, $jobFiles); |
| 177 | 179 | } |
| 178 | 180 | } |
@@ -259,7 +261,8 @@ discard block |
||
| 259 | 261 | foreach ($this->getMarathonEntitiesForConfig($temp) as $app) { |
| 260 | 262 | $jobEntities[] = $app; |
| 261 | 263 | } |
| 262 | - } else { |
|
| 264 | + } |
|
| 265 | + else { |
|
| 263 | 266 | throw new JobLoadException( |
| 264 | 267 | 'Could not distinguish job as either chronos or marathon', |
| 265 | 268 | JobLoadException::ERROR_CODE_UNKNOWN_ENTITY_TYPE |
@@ -275,7 +278,8 @@ discard block |
||
| 275 | 278 | |
| 276 | 279 | $jobs[] = $jobEntity; |
| 277 | 280 | } |
| 278 | - } else { |
|
| 281 | + } |
|
| 282 | + else { |
|
| 279 | 283 | throw new JobLoadException( |
| 280 | 284 | sprintf('Unable to load json job data from "%s". Please check if the json is valid.', $jobFilePath), |
| 281 | 285 | JobLoadException::ERROR_CODE_NO_VALID_JSON |
@@ -297,7 +301,8 @@ discard block |
||
| 297 | 301 | $this->groupedApps[] = $app->id; |
| 298 | 302 | $return[] = $groupEntity; |
| 299 | 303 | } |
| 300 | - } else { |
|
| 304 | + } |
|
| 305 | + else { |
|
| 301 | 306 | $return[] = new MarathonAppEntity($entityData); |
| 302 | 307 | } |
| 303 | 308 | return $return; |
@@ -356,7 +361,8 @@ discard block |
||
| 356 | 361 | } |
| 357 | 362 | return false; |
| 358 | 363 | } |
| 359 | - } else { |
|
| 364 | + } |
|
| 365 | + else { |
|
| 360 | 366 | $decodedConfig->apps[$key] = $jobEntity; |
| 361 | 367 | } |
| 362 | 368 | $appFound = true; |
@@ -93,7 +93,8 @@ |
||
| 93 | 93 | foreach ($profileConfig['ignore'] as $searchPattern) { |
| 94 | 94 | if ('!' == substr($searchPattern, 0, 1)) { |
| 95 | 95 | $searchPatterns['ignore_not'][] = substr($searchPattern, 1); |
| 96 | - } else { |
|
| 96 | + } |
|
| 97 | + else { |
|
| 97 | 98 | $searchPatterns['ignore'][] = $searchPattern; |
| 98 | 99 | } |
| 99 | 100 | } |
@@ -58,7 +58,8 @@ |
||
| 58 | 58 | |
| 59 | 59 | if (!empty($jobEntity->schedule) && empty($jobEntity->parents)) { |
| 60 | 60 | $targetUrl = '/scheduler/iso8601'; |
| 61 | - } elseif (empty($jobEntity->schedule) && !empty($jobEntity->parents)) { |
|
| 61 | + } |
|
| 62 | + elseif (empty($jobEntity->schedule) && !empty($jobEntity->parents)) { |
|
| 62 | 63 | $targetUrl = '/scheduler/dependency'; |
| 63 | 64 | } |
| 64 | 65 | |