@@ -67,8 +67,9 @@ discard block |
||
| 67 | 67 | public function parseResponse($responseLine, $responseData) |
| 68 | 68 | { |
| 69 | 69 | |
| 70 | - if (!(isset($responseData['workflow']))) |
|
| 71 | - return false; |
|
| 70 | + if (!(isset($responseData['workflow']))) { |
|
| 71 | + return false; |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | $subjobs = $responseData['workflow']['subjobs']; |
| 74 | 75 | $jobInstances = new ArrayCollection([]); |
@@ -77,9 +78,12 @@ discard block |
||
| 77 | 78 | foreach($subjob['tasks'] as $tasks) { |
| 78 | 79 | $task = $tasks['@attributes']; |
| 79 | 80 | |
| 80 | - if (isset($task['execution_time'])) $task['execution_time'] = new \DateTime($task['execution_time']); |
|
| 81 | - foreach($task as $key => $val) |
|
| 82 | - if (ctype_digit($val)) $task[$key] = (int) $task[$key]; |
|
| 81 | + if (isset($task['execution_time'])) { |
|
| 82 | + $task['execution_time'] = new \DateTime($task['execution_time']); |
|
| 83 | + } |
|
| 84 | + foreach($task as $key => $val) { |
|
| 85 | + if (ctype_digit($val)) $task[$key] = (int) $task[$key]; |
|
| 86 | + } |
|
| 83 | 87 | $taskInstances[] = new TaskInstance($task); |
| 84 | 88 | } |
| 85 | 89 | $jobInstances[] = new JobInstance($taskInstances); |
@@ -79,7 +79,9 @@ |
||
| 79 | 79 | $mostRecent = $date; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | - if (empty($responseData)) return $this->parseResponse($responseLine, $responseData); |
|
| 82 | + if (empty($responseData)) { |
|
| 83 | + return $this->parseResponse($responseLine, $responseData); |
|
| 84 | + } |
|
| 83 | 85 | return $this->_createResponse( |
| 84 | 86 | Response::RESPONSE_FOUND, |
| 85 | 87 | array( |
@@ -76,8 +76,9 @@ discard block |
||
| 76 | 76 | 'offset' => $offset, |
| 77 | 77 | 'limit' => $limit |
| 78 | 78 | ]; |
| 79 | - if (!empty($this->workflow)) |
|
| 80 | - $filters['filter_workflow'] = $this->workflow->getName(); |
|
| 79 | + if (!empty($this->workflow)) { |
|
| 80 | + $filters['filter_workflow'] = $this->workflow->getName(); |
|
| 81 | + } |
|
| 81 | 82 | |
| 82 | 83 | return $filters; |
| 83 | 84 | } |
@@ -88,18 +89,24 @@ discard block |
||
| 88 | 89 | public function parseResponse($responseLine, $responseData) |
| 89 | 90 | { |
| 90 | 91 | |
| 91 | - if (!(isset($responseData['workflow']))) |
|
| 92 | - return new ArrayCollection([]); |
|
| 92 | + if (!(isset($responseData['workflow']))) { |
|
| 93 | + return new ArrayCollection([]); |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | $instances = $responseData['workflow'] ; |
| 95 | 97 | $instances = isset($instances['tags']) ? [$instances['@attributes']] : $instances; |
| 96 | 98 | $workflowInstances = new ArrayCollection([]); |
| 97 | 99 | foreach($instances as $instance) { |
| 98 | 100 | $instance = $instance['@attributes'] ?? $instance; |
| 99 | - if (isset($instance['start_time'])) $instance['start_time'] = new \DateTime($instance['start_time']); |
|
| 100 | - if (isset($instance['end_time'])) $instance['end_time'] = new \DateTime($instance['end_time']); |
|
| 101 | - foreach($instance as $key => $val) |
|
| 102 | - if (ctype_digit($val)) $instance[$key] = (int) $instance[$key]; |
|
| 101 | + if (isset($instance['start_time'])) { |
|
| 102 | + $instance['start_time'] = new \DateTime($instance['start_time']); |
|
| 103 | + } |
|
| 104 | + if (isset($instance['end_time'])) { |
|
| 105 | + $instance['end_time'] = new \DateTime($instance['end_time']); |
|
| 106 | + } |
|
| 107 | + foreach($instance as $key => $val) { |
|
| 108 | + if (ctype_digit($val)) $instance[$key] = (int) $instance[$key]; |
|
| 109 | + } |
|
| 103 | 110 | $workflowInstances[] = new WorkflowInstance($instance); |
| 104 | 111 | } |
| 105 | 112 | $collection['rows'] = (int) (isset($responseData['@attributes']['rows'])) ? |
@@ -113,8 +113,9 @@ |
||
| 113 | 113 | public function workflowExists($name) |
| 114 | 114 | { |
| 115 | 115 | $workflow = $this->_dispatch(new Command\WorkflowExistsCommand($name)); |
| 116 | - if ($workflow instanceof Workflow) |
|
| 117 | - return $this->getCurrentClass()->getWorkflow($workflow); |
|
| 116 | + if ($workflow instanceof Workflow) { |
|
| 117 | + return $this->getCurrentClass()->getWorkflow($workflow); |
|
| 118 | + } |
|
| 118 | 119 | return false; |
| 119 | 120 | } |
| 120 | 121 | |
@@ -69,18 +69,23 @@ |
||
| 69 | 69 | $properties = $thisObject->getProperties(); |
| 70 | 70 | foreach ($properties as $property) { |
| 71 | 71 | $snakeProperty = $this->from_camel_case($property->getName()); |
| 72 | - if (isset($params[$snakeProperty])) |
|
| 73 | - $this->{$property->getName()} = $params[$snakeProperty]; |
|
| 72 | + if (isset($params[$snakeProperty])) { |
|
| 73 | + $this->{$property->getName()} = $params[$snakeProperty]; |
|
| 74 | + } |
|
| 74 | 75 | } |
| 75 | 76 | if (!is_null($this->getRunningTasks()) && !is_null($this->getQueuedTasks()) |
| 76 | - && $this->getRunningTasks() - $this->getQueuedTasks() > 0 ) |
|
| 77 | - $this->setStatus(self::STATUS_RUNNING); |
|
| 78 | - if (!is_null($this->getQueuedTasks()) && $this->getQueuedTasks() > 0 ) |
|
| 79 | - $this->setStatus(self::STATUS_QUEUED); |
|
| 80 | - if (!is_null($this->getRetryingTasks()) && $this->getRetryingTasks() > 0) |
|
| 81 | - $this->setStatus(self::STATUS_RETRYING); |
|
| 82 | - if (!is_null($this->getErrors()) && $this->getErrors() > 0) |
|
| 83 | - $this->setStatus(self::STATUS_FAILED); |
|
| 77 | + && $this->getRunningTasks() - $this->getQueuedTasks() > 0 ) { |
|
| 78 | + $this->setStatus(self::STATUS_RUNNING); |
|
| 79 | + } |
|
| 80 | + if (!is_null($this->getQueuedTasks()) && $this->getQueuedTasks() > 0 ) { |
|
| 81 | + $this->setStatus(self::STATUS_QUEUED); |
|
| 82 | + } |
|
| 83 | + if (!is_null($this->getRetryingTasks()) && $this->getRetryingTasks() > 0) { |
|
| 84 | + $this->setStatus(self::STATUS_RETRYING); |
|
| 85 | + } |
|
| 86 | + if (!is_null($this->getErrors()) && $this->getErrors() > 0) { |
|
| 87 | + $this->setStatus(self::STATUS_FAILED); |
|
| 88 | + } |
|
| 84 | 89 | } |
| 85 | 90 | |
| 86 | 91 | /** |
@@ -39,8 +39,9 @@ |
||
| 39 | 39 | $properties = $thisObject->getProperties(); |
| 40 | 40 | foreach ($properties as $property) { |
| 41 | 41 | $snakeProperty = $this->from_camel_case($property->getName()); |
| 42 | - if (isset($params[$snakeProperty])) |
|
| 43 | - $this->{$property->getName()} = $params[$snakeProperty]; |
|
| 42 | + if (isset($params[$snakeProperty])) { |
|
| 43 | + $this->{$property->getName()} = $params[$snakeProperty]; |
|
| 44 | + } |
|
| 44 | 45 | } |
| 45 | 46 | } |
| 46 | 47 | |
@@ -66,8 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function setSeconds(array $seconds): TimeSchedule |
| 68 | 68 | { |
| 69 | - if (count( $seconds ) !== count( array_filter( $seconds, 'is_numeric' )) || array_sum($seconds) > self::SUM_SUBUNIT_IN_UNIT ) |
|
| 70 | - throw new \Exception('Wrong units of time'); |
|
| 69 | + if (count( $seconds ) !== count( array_filter( $seconds, 'is_numeric' )) || array_sum($seconds) > self::SUM_SUBUNIT_IN_UNIT ) { |
|
| 70 | + throw new \Exception('Wrong units of time'); |
|
| 71 | + } |
|
| 71 | 72 | $this->seconds = $seconds; |
| 72 | 73 | return $this; |
| 73 | 74 | } |
@@ -87,8 +88,9 @@ discard block |
||
| 87 | 88 | */ |
| 88 | 89 | public function setMinutes(array $minutes): TimeSchedule |
| 89 | 90 | { |
| 90 | - if (count( $minutes ) !== count( array_filter( $minutes, 'is_numeric' )) || array_sum($minutes) > self::SUM_SUBUNIT_IN_UNIT ) |
|
| 91 | - throw new \Exception('Wrong units of time'); |
|
| 91 | + if (count( $minutes ) !== count( array_filter( $minutes, 'is_numeric' )) || array_sum($minutes) > self::SUM_SUBUNIT_IN_UNIT ) { |
|
| 92 | + throw new \Exception('Wrong units of time'); |
|
| 93 | + } |
|
| 92 | 94 | $this->minutes = $minutes; |
| 93 | 95 | return $this; |
| 94 | 96 | } |
@@ -108,8 +110,9 @@ discard block |
||
| 108 | 110 | */ |
| 109 | 111 | public function setHours(array $hours): TimeSchedule |
| 110 | 112 | { |
| 111 | - if (count( $hours ) !== count( array_filter( $hours, 'is_numeric' )) || array_sum($hours) > self::SUM_HOURS ) |
|
| 112 | - throw new \Exception('Wrong units of time'); |
|
| 113 | + if (count( $hours ) !== count( array_filter( $hours, 'is_numeric' )) || array_sum($hours) > self::SUM_HOURS ) { |
|
| 114 | + throw new \Exception('Wrong units of time'); |
|
| 115 | + } |
|
| 113 | 116 | $this->hours = $hours; |
| 114 | 117 | return $this; |
| 115 | 118 | } |
@@ -129,8 +132,9 @@ discard block |
||
| 129 | 132 | */ |
| 130 | 133 | public function setDays(array $days): TimeSchedule |
| 131 | 134 | { |
| 132 | - if (count( $days ) !== count( array_filter( $days, 'is_numeric' )) || array_sum($days) > self::SUM_DAYS ) |
|
| 133 | - throw new \Exception('Wrong units of time'); |
|
| 135 | + if (count( $days ) !== count( array_filter( $days, 'is_numeric' )) || array_sum($days) > self::SUM_DAYS ) { |
|
| 136 | + throw new \Exception('Wrong units of time'); |
|
| 137 | + } |
|
| 134 | 138 | $this->days = $days; |
| 135 | 139 | return $this; |
| 136 | 140 | } |
@@ -150,8 +154,9 @@ discard block |
||
| 150 | 154 | */ |
| 151 | 155 | public function setMonths(array $months): TimeSchedule |
| 152 | 156 | { |
| 153 | - if (count( $months ) !== count( array_filter( $months, 'is_numeric' )) || array_sum($months) > self::SUM_MONTHS ) |
|
| 154 | - throw new \Exception('Wrong units of time'); |
|
| 157 | + if (count( $months ) !== count( array_filter( $months, 'is_numeric' )) || array_sum($months) > self::SUM_MONTHS ) { |
|
| 158 | + throw new \Exception('Wrong units of time'); |
|
| 159 | + } |
|
| 155 | 160 | $this->months = $months; |
| 156 | 161 | return $this; |
| 157 | 162 | } |
@@ -100,10 +100,11 @@ |
||
| 100 | 100 | public function setDynamic($dynamic): Tube |
| 101 | 101 | { |
| 102 | 102 | if (!is_bool($dynamic)) { |
| 103 | - if($dynamic === self::IS_NOT_DYNAMIC) |
|
| 104 | - $dynamic = false; |
|
| 105 | - else |
|
| 106 | - $dynamic = true; |
|
| 103 | + if($dynamic === self::IS_NOT_DYNAMIC) { |
|
| 104 | + $dynamic = false; |
|
| 105 | + } else { |
|
| 106 | + $dynamic = true; |
|
| 107 | + } |
|
| 107 | 108 | } |
| 108 | 109 | $this->dynamic = $dynamic; |
| 109 | 110 | return $this; |
@@ -195,8 +195,9 @@ |
||
| 195 | 195 | protected function build_query($name, $action = false, $attributes = [], $parameters = []){ |
| 196 | 196 | $dom = new \DOMDocument("1.0", "utf-8"); |
| 197 | 197 | $root = $dom->createElement($name); |
| 198 | - if($action) |
|
| 199 | - $root->setAttribute('action', $action); |
|
| 198 | + if($action) { |
|
| 199 | + $root->setAttribute('action', $action); |
|
| 200 | + } |
|
| 200 | 201 | foreach ($attributes as $key => $value) { |
| 201 | 202 | $root->setAttribute($key, $value); |
| 202 | 203 | } |