@@ -28,15 +28,18 @@ discard block |
||
28 | 28 | $this->printout = $printout; |
29 | 29 | $this->logPath = "/var/tmp/logs/cpe/"; |
30 | 30 | |
31 | - if ($logPath) |
|
32 | - $this->logPath = $logPath; |
|
31 | + if ($logPath) { |
|
32 | + $this->logPath = $logPath; |
|
33 | + } |
|
33 | 34 | |
34 | - if (!file_exists($this->logPath)) |
|
35 | - mkdir($this->logPath, 0755, true); |
|
35 | + if (!file_exists($this->logPath)) { |
|
36 | + mkdir($this->logPath, 0755, true); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $file = basename($argv[0]); |
38 | - if ($suffix) |
|
39 | - $file .= "-".$suffix; |
|
40 | + if ($suffix) { |
|
41 | + $file .= "-".$suffix; |
|
42 | + } |
|
40 | 43 | // Append progname to the path |
41 | 44 | $this->logPath .= "/".$file.".log"; |
42 | 45 | |
@@ -60,13 +63,15 @@ discard block |
||
60 | 63 | "message" => $message |
61 | 64 | ]; |
62 | 65 | |
63 | - if ($workflowId) |
|
64 | - $log["workflowId"] = $workflowId; |
|
66 | + if ($workflowId) { |
|
67 | + $log["workflowId"] = $workflowId; |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Open Syslog. Use programe name as key |
67 | - if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1)) |
|
68 | - throw new CpeException("Unable to connect to Syslog!", |
|
71 | + if (!openlog (__FILE__, LOG_CONS|LOG_PID, LOG_LOCAL1)) { |
|
72 | + throw new CpeException("Unable to connect to Syslog!", |
|
69 | 73 | OPENLOG_ERROR); |
74 | + } |
|
70 | 75 | |
71 | 76 | // Change Syslog priority level |
72 | 77 | switch ($type) |
@@ -103,22 +108,26 @@ discard block |
||
103 | 108 | // Write log in file |
104 | 109 | private function print_to_file($log, $workflowId) |
105 | 110 | { |
106 | - if (!is_string($log['message'])) |
|
107 | - $log['message'] = json_encode($log['message']); |
|
111 | + if (!is_string($log['message'])) { |
|
112 | + $log['message'] = json_encode($log['message']); |
|
113 | + } |
|
108 | 114 | |
109 | 115 | $toPrint = $log['time'] . " [" . $log['type'] . "] [" . $log['source'] . "] "; |
110 | 116 | // If there is a workflow ID. We append it. |
111 | - if ($workflowId) |
|
112 | - $toPrint .= "[$workflowId] "; |
|
117 | + if ($workflowId) { |
|
118 | + $toPrint .= "[$workflowId] "; |
|
119 | + } |
|
113 | 120 | $toPrint .= $log['message'] . "\n"; |
114 | 121 | |
115 | - if ($this->printout) |
|
116 | - print $toPrint; |
|
122 | + if ($this->printout) { |
|
123 | + print $toPrint; |
|
124 | + } |
|
117 | 125 | |
118 | 126 | if (file_put_contents( |
119 | 127 | $this->logPath, |
120 | 128 | $toPrint, |
121 | - FILE_APPEND) === false) |
|
122 | - print "ERROR: Can't write into log file!\n"; |
|
129 | + FILE_APPEND) === false) { |
|
130 | + print "ERROR: Can't write into log file!\n"; |
|
131 | + } |
|
123 | 132 | } |
124 | 133 | } |
125 | 134 | \ No newline at end of file |
@@ -47,21 +47,24 @@ discard block |
||
47 | 47 | $this->params = $params; |
48 | 48 | |
49 | 49 | // Check if there is an activity name |
50 | - if (!isset($params["name"]) || !$params["name"]) |
|
51 | - throw new CpeSdk\CpeException("Can't instantiate BasicActivity: 'name' is not provided or empty !\n", |
|
50 | + if (!isset($params["name"]) || !$params["name"]) { |
|
51 | + throw new CpeSdk\CpeException("Can't instantiate BasicActivity: 'name' is not provided or empty !\n", |
|
52 | 52 | self::NO_ACTIVITY_NAME); |
53 | + } |
|
53 | 54 | |
54 | - if (!$cpeLogger) |
|
55 | - $this->cpeLogger = new CpeSdk\CpeLogger(null, $params["name"], $debug); |
|
56 | - else |
|
57 | - $this->cpeLogger = $cpeLogger; |
|
55 | + if (!$cpeLogger) { |
|
56 | + $this->cpeLogger = new CpeSdk\CpeLogger(null, $params["name"], $debug); |
|
57 | + } else { |
|
58 | + $this->cpeLogger = $cpeLogger; |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // Create logger object. Use activity name for logger |
60 | 62 | |
61 | 63 | // Check if there is a version name |
62 | - if (!isset($params["version"]) || !$params["version"]) |
|
63 | - throw new CpeSdk\CpeException("Can't instantiate BasicActivity: 'version' is not provided or empty !\n", |
|
64 | + if (!isset($params["version"]) || !$params["version"]) { |
|
65 | + throw new CpeSdk\CpeException("Can't instantiate BasicActivity: 'version' is not provided or empty !\n", |
|
64 | 66 | self::NO_ACTIVITY_VERSION); |
67 | + } |
|
65 | 68 | |
66 | 69 | // Initialize the activity in SWF if necessary |
67 | 70 | $this->init_activity(); |
@@ -104,14 +107,16 @@ discard block |
||
104 | 107 | */ |
105 | 108 | public function do_task_check($task) |
106 | 109 | { |
107 | - if (!$task) |
|
108 | - throw new CpeSdk\CpeException("Activity Task empty !", |
|
109 | - self::ACTIVITY_TASK_EMPTY); |
|
110 | + if (!$task) { |
|
111 | + throw new CpeSdk\CpeException("Activity Task empty !", |
|
112 | + self::ACTIVITY_TASK_EMPTY); |
|
113 | + } |
|
110 | 114 | |
111 | 115 | if (!isset($task["input"]) || !$task["input"] || |
112 | - $task["input"] == "") |
|
113 | - throw new CpeSdk\CpeException("No input provided to 'Activity'", |
|
116 | + $task["input"] == "") { |
|
117 | + throw new CpeSdk\CpeException("No input provided to 'Activity'", |
|
114 | 118 | self::NO_INPUT); |
119 | + } |
|
115 | 120 | |
116 | 121 | // Save input string |
117 | 122 | $this->input_str = $task["input"]; |
@@ -133,9 +138,10 @@ discard block |
||
133 | 138 | public function do_input_validation() |
134 | 139 | { |
135 | 140 | // Check JSON input |
136 | - if (!($this->input = json_decode($this->input_str))) |
|
137 | - throw new CpeSdk\CpeException("JSON input is invalid !", |
|
141 | + if (!($this->input = json_decode($this->input_str))) { |
|
142 | + throw new CpeSdk\CpeException("JSON input is invalid !", |
|
138 | 143 | self::INPUT_INVALID); |
144 | + } |
|
139 | 145 | } |
140 | 146 | |
141 | 147 | /** |