@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | public function getLocalMissingJobs() |
| 35 | 35 | { |
| 36 | 36 | $_aMissingJobs = array(); |
| 37 | - foreach($this->aComposites as $jobComparers) |
|
| 37 | + foreach ($this->aComposites as $jobComparers) |
|
| 38 | 38 | { |
| 39 | 39 | $missing = $jobComparers->getLocalMissingJobs(); |
| 40 | - $_aMissingJobs = array_merge($_aMissingJobs, $missing); |
|
| 40 | + $_aMissingJobs = array_merge($_aMissingJobs, $missing); |
|
| 41 | 41 | } |
| 42 | 42 | return $_aMissingJobs; |
| 43 | 43 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public function getRemoteMissingJobs() |
| 49 | 49 | { |
| 50 | 50 | $_aChronosMissingJobs = array(); |
| 51 | - foreach($this->aComposites as $jobComparers) |
|
| 51 | + foreach ($this->aComposites as $jobComparers) |
|
| 52 | 52 | { |
| 53 | 53 | $_aChronosMissingJobs = array_merge($_aChronosMissingJobs, $jobComparers->getRemoteMissingJobs()); |
| 54 | 54 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function getLocalJobUpdates() |
| 62 | 62 | { |
| 63 | 63 | $_aLocalJobUpdates = array(); |
| 64 | - foreach($this->aComposites as $jobComparers) |
|
| 64 | + foreach ($this->aComposites as $jobComparers) |
|
| 65 | 65 | { |
| 66 | 66 | $_aLocalJobUpdates = array_merge($_aLocalJobUpdates, $jobComparers->getLocalJobUpdates()); |
| 67 | 67 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function getJobDiff($sJobName) |
| 76 | 76 | { |
| 77 | 77 | $_aJobDiffs = array(); |
| 78 | - foreach($this->aComposites as $jobComparers) |
|
| 78 | + foreach ($this->aComposites as $jobComparers) |
|
| 79 | 79 | { |
| 80 | 80 | // assuming same name won't be in all subsystems. |
| 81 | 81 | // TODO: add support to handle the duplicate names in different subsystems |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | /** @var JobComparisonInterface $comparer */ |
| 103 | 103 | $comparer = null; |
| 104 | - foreach($this->aComposites as $child) |
|
| 104 | + foreach ($this->aComposites as $child) |
|
| 105 | 105 | { |
| 106 | 106 | if ($child->isJobAvailable($oJobEntityA->getKey())) |
| 107 | 107 | { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function isJobAvailable($sJobName) |
| 127 | 127 | { |
| 128 | - foreach($this->aComposites as $child) |
|
| 128 | + foreach ($this->aComposites as $child) |
|
| 129 | 129 | { |
| 130 | 130 | if ($child->isJobAvailable($sJobName)) |
| 131 | 131 | { |
@@ -59,48 +59,42 @@ |
||
| 59 | 59 | { |
| 60 | 60 | $_oResponse = $this->oGuzzelClient->request('GET', $sUrl, $_aRequestOptions); |
| 61 | 61 | return new HttpGuzzlResponse($_oResponse); |
| 62 | - } |
|
| 63 | - catch (ClientException $oException) // 400 level errors |
|
| 62 | + } catch (ClientException $oException) // 400 level errors |
|
| 64 | 63 | { |
| 65 | 64 | throw new HttpConnectionException( |
| 66 | 65 | sprintf('Client error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
| 67 | 66 | $oException->getCode(), |
| 68 | 67 | $oException |
| 69 | 68 | ); |
| 70 | - } |
|
| 71 | - catch (ServerException $oException) // 500 level errors |
|
| 69 | + } catch (ServerException $oException) // 500 level errors |
|
| 72 | 70 | { |
| 73 | 71 | throw new HttpConnectionException( |
| 74 | 72 | sprintf('Server error: Calling %s returned %d', $this->oGuzzelClient->getConfig('base_uri') . $sUrl, $oException->getCode()), |
| 75 | 73 | $oException->getCode(), |
| 76 | 74 | $oException |
| 77 | 75 | ); |
| 78 | - } |
|
| 79 | - catch (TooManyRedirectsException $oException) // too many redirects to follow |
|
| 76 | + } catch (TooManyRedirectsException $oException) // too many redirects to follow |
|
| 80 | 77 | { |
| 81 | 78 | throw new HttpConnectionException( |
| 82 | 79 | sprintf('Request to %s failed due to too many redirects', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 83 | 80 | HttpConnectionException::ERROR_CODE_TOO_MANY_REDIRECT_EXCEPTION, |
| 84 | 81 | $oException |
| 85 | 82 | ); |
| 86 | - } |
|
| 87 | - catch (ConnectException $oException) // networking error |
|
| 83 | + } catch (ConnectException $oException) // networking error |
|
| 88 | 84 | { |
| 89 | 85 | throw new HttpConnectionException( |
| 90 | 86 | sprintf('Cannot connect to %s due to some networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 91 | 87 | HttpConnectionException::ERROR_CODE_CONNECT_EXCEPTION, |
| 92 | 88 | $oException |
| 93 | 89 | ); |
| 94 | - } |
|
| 95 | - catch (RequestException $oException) // networking error (connection timeout, DNS errors, etc.) |
|
| 90 | + } catch (RequestException $oException) // networking error (connection timeout, DNS errors, etc.) |
|
| 96 | 91 | { |
| 97 | 92 | throw new HttpConnectionException( |
| 98 | 93 | sprintf('Cannot connect to %s due to networking error', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
| 99 | 94 | HttpConnectionException::ERROR_CODE_REQUEST_EXCEPTION, |
| 100 | 95 | $oException |
| 101 | 96 | ); |
| 102 | - } |
|
| 103 | - catch (\Exception $oException) |
|
| 97 | + } catch (\Exception $oException) |
|
| 104 | 98 | { |
| 105 | 99 | throw new HttpConnectionException( |
| 106 | 100 | sprintf('Can\'t get response from "%s"', $this->oGuzzelClient->getConfig('base_uri') . $sUrl), |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function __construct($aData = []) |
| 25 | 25 | { |
| 26 | - MarathonEntityUtils::setAllPossibleProperties((array)$aData, $this); |
|
| 27 | - if(isset($aData['labels'])) |
|
| 26 | + MarathonEntityUtils::setAllPossibleProperties((array) $aData, $this); |
|
| 27 | + if (isset($aData['labels'])) |
|
| 28 | 28 | { |
| 29 | - $this->labels = (object)$aData['labels']; |
|
| 29 | + $this->labels = (object) $aData['labels']; |
|
| 30 | 30 | } else { |
| 31 | - $this->labels = (object)[]; |
|
| 31 | + $this->labels = (object) []; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $_aRet = (array) $this; |
| 42 | 42 | $_aRet = array_filter($_aRet, function($v, $k) { |
| 43 | 43 | return !is_null($v); |
| 44 | - }, ARRAY_FILTER_USE_BOTH ); |
|
| 44 | + }, ARRAY_FILTER_USE_BOTH); |
|
| 45 | 45 | return $_aRet; |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -27,7 +27,8 @@ |
||
| 27 | 27 | if(isset($aData['labels'])) |
| 28 | 28 | { |
| 29 | 29 | $this->labels = (object)$aData['labels']; |
| 30 | - } else { |
|
| 30 | + } |
|
| 31 | + else { |
|
| 31 | 32 | $this->labels = (object)[]; |
| 32 | 33 | } |
| 33 | 34 | |
@@ -183,7 +183,8 @@ discard block |
||
| 183 | 183 | if (is_file($_sPath) && preg_match('~\.json~i', $_sPath)) |
| 184 | 184 | { |
| 185 | 185 | $aJobFiles[] = $_sPath; |
| 186 | - } elseif (is_dir($_sPath)) |
|
| 186 | + } |
|
| 187 | + elseif (is_dir($_sPath)) |
|
| 187 | 188 | { |
| 188 | 189 | $this->getJobFilesFromFileSystem($_sPath, $aJobFiles); |
| 189 | 190 | } |
@@ -268,17 +269,23 @@ discard block |
||
| 268 | 269 | |
| 269 | 270 | if ($_aTemp) |
| 270 | 271 | { |
| 271 | - if (property_exists($_aTemp, 'name')) // chronos |
|
| 272 | + if (property_exists($_aTemp, 'name')) { |
|
| 273 | + // chronos |
|
| 272 | 274 | { |
| 273 | 275 | $_aJobEntities[] = new ChronosJobEntity($_aTemp); |
| 276 | + } |
|
| 274 | 277 | |
| 275 | - } else if (property_exists($_aTemp, 'id')) //marathon |
|
| 278 | + } |
|
| 279 | + else if (property_exists($_aTemp, 'id')) { |
|
| 280 | + //marathon |
|
| 276 | 281 | { |
| 277 | 282 | foreach ($this->getMarathonEntitiesForConfig($_aTemp) as $_oApp) |
| 278 | 283 | { |
| 279 | 284 | $_aJobEntities[] = $_oApp; |
| 285 | + } |
|
| 280 | 286 | } |
| 281 | - } else { |
|
| 287 | + } |
|
| 288 | + else { |
|
| 282 | 289 | throw new JobLoadException( |
| 283 | 290 | 'Could not distinguish job as either chronos or marathon', |
| 284 | 291 | JobLoadException::ERROR_CODE_UNKNOWN_ENTITY_TYPE |
@@ -385,7 +392,8 @@ discard block |
||
| 385 | 392 | } |
| 386 | 393 | return false; |
| 387 | 394 | } |
| 388 | - } else { |
|
| 395 | + } |
|
| 396 | + else { |
|
| 389 | 397 | $_oDecodedConfig->apps[$key] = $oJobEntity; |
| 390 | 398 | } |
| 391 | 399 | $_bAppFound = true; |
@@ -70,7 +70,8 @@ |
||
| 70 | 70 | if (null == $_oLocalEntity) |
| 71 | 71 | { |
| 72 | 72 | $this->addJobInLocalRepository($_oRemoteEntity); |
| 73 | - } else { |
|
| 73 | + } |
|
| 74 | + else { |
|
| 74 | 75 | //update |
| 75 | 76 | $this->updateJobInLocalRepository($_oRemoteEntity, $bForceOverwrite); |
| 76 | 77 | } |
@@ -62,7 +62,8 @@ |
||
| 62 | 62 | if (!empty($oJobEntity->schedule) && empty($oJobEntity->parents)) |
| 63 | 63 | { |
| 64 | 64 | $_sTargetUrl = '/scheduler/iso8601'; |
| 65 | - } elseif (empty($oJobEntity->schedule) && !empty($oJobEntity->parents)) |
|
| 65 | + } |
|
| 66 | + elseif (empty($oJobEntity->schedule) && !empty($oJobEntity->parents)) |
|
| 66 | 67 | { |
| 67 | 68 | $_sTargetUrl = '/scheduler/dependency'; |
| 68 | 69 | } |
@@ -38,8 +38,7 @@ |
||
| 38 | 38 | try |
| 39 | 39 | { |
| 40 | 40 | return self::$aIso8601Entity[$_sKey] = new Iso8601Entity($sIso8601); |
| 41 | - } |
|
| 42 | - catch (\InvalidArgumentException $_oException) |
|
| 41 | + } catch (\InvalidArgumentException $_oException) |
|
| 43 | 42 | { |
| 44 | 43 | throw new DatePeriodException(sprintf("Can't init Iso8601Entity for '%s' iso 8601 string.", $sIso8601), 1, $_oException); |
| 45 | 44 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | * @param string $sDirectoryPath |
| 97 | 97 | * @param array $aSearchPatterns |
| 98 | 98 | */ |
| 99 | - private function getSearchPatternsFromDir($sDirectoryPath, &$aSearchPatterns=[]) |
|
| 99 | + private function getSearchPatternsFromDir($sDirectoryPath, &$aSearchPatterns = []) |
|
| 100 | 100 | { |
| 101 | 101 | $_sIgnoreFilePath = $sDirectoryPath . DIRECTORY_SEPARATOR . '.chapiignore'; |
| 102 | 102 | |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | */ |
| 68 | 68 | public function removeJob($sJobName) |
| 69 | 69 | { |
| 70 | - $_sTargetEndpoint = '/v2/apps/'.$sJobName; |
|
| 70 | + $_sTargetEndpoint = '/v2/apps/' . $sJobName; |
|
| 71 | 71 | |
| 72 | 72 | $_oResponse = $this->oHttpClient->delete($_sTargetEndpoint); |
| 73 | 73 | return ($_oResponse->getStatusCode() == 200); |