Code Duplication    Length = 38-39 lines in 2 locations

src/Comodojo/Extender/Tasks/AbstractTask.php 1 location

@@ 127-164 (lines=38) @@
124
     * - setup worklog
125
     * - invoke method "run", that should be defined in task implementation
126
     */
127
    private function execTask() {
128
129
        try {
130
131
            // open worklog
132
133
            $this->worklog_id = $this->worklog->create($this->pid, $this->name, $this->class, $this->start_timestamp);
134
135
            $this->result = $this->run();
136
137
            $this->end_timestamp = microtime(true);
138
139
            $this->closeWorklog(true);
140
141
        } catch (Exception $e) {
142
143
            $this->result = $e->getMessage();
144
145
            if ( !is_null($this->worklog_id) ) {
146
147
                if ( is_null($this->end_timestamp) ) $this->end_timestamp = microtime(true);
148
149
                $this->closeWorklog(false);
150
151
            }
152
153
            throw $e;
154
155
        }
156
157
        return array(
158
            "success"   => true,
159
            "timestamp" => $this->end_timestamp,
160
            "result"    => $this->result,
161
            "worklogid" => $this->worklog_id
162
        );
163
164
    }
165
    
166
}

src/Task/Task.php 1 location

@@ 260-298 (lines=39) @@
257
     * - setup worklog
258
     * - invoke method "run", that should be defined in task implementation
259
     */
260
    private function execTask() {
261
262
        try {
263
264
            // open worklog
265
266
            $this->worklog_id = $this->createWorklog($this->pid, $this->name, $this->class, $this->start_timestamp);
267
268
            $this->result = $this->run();
269
270
            $this->end_timestamp = microtime(true);
271
272
            $this->closeWorklog(true);
273
274
        }
275
        catch (Exception $e) {
276
277
            $this->result = $e->getMessage();
278
279
            if ( !is_null($this->worklog_id) ) {
280
281
                if ( is_null($this->end_timestamp) ) $this->end_timestamp = microtime(true);
282
283
                $this->closeWorklog(false);
284
285
            }
286
287
            throw $e;
288
289
        }
290
291
        return array(
292
            "success"   => true,
293
            "timestamp" => $this->end_timestamp,
294
            "result"    => $this->result,
295
            "worklogid" => $this->worklog_id
296
        );
297
298
    }
299
300
    /**
301
     * The run method; SHOULD be implemented by each task