These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace Comodojo\Extender\Runner; |
||
2 | |||
3 | /** |
||
4 | * Jobs result object |
||
5 | * |
||
6 | * @package Comodojo extender |
||
7 | * @author Marco Giovinazzi <[email protected]> |
||
8 | * @license GPL-3.0+ |
||
9 | * |
||
10 | * LICENSE: |
||
11 | * |
||
12 | * This program is free software: you can redistribute it and/or modify |
||
13 | * it under the terms of the GNU Affero General Public License as |
||
14 | * published by the Free Software Foundation, either version 3 of the |
||
15 | * License, or (at your option) any later version. |
||
16 | * |
||
17 | * This program is distributed in the hope that it will be useful, |
||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
20 | * GNU Affero General Public License for more details. |
||
21 | * |
||
22 | * You should have received a copy of the GNU Affero General Public License |
||
23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
24 | */ |
||
25 | |||
26 | class JobsResult { |
||
27 | |||
28 | /** |
||
29 | * Tasks database (a simple array!). |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $completed_processes = array(); |
||
34 | |||
35 | /** |
||
36 | * Class constructor |
||
37 | * |
||
38 | * @param array $processes |
||
39 | */ |
||
40 | 3 | final public function __construct($processes) { |
|
41 | |||
42 | 3 | $this->completed_processes = $processes; |
|
43 | |||
44 | 3 | } |
|
45 | |||
46 | /** |
||
47 | * Get raw results |
||
48 | * |
||
49 | * @param bool $raw If true, results will be returned as NUM array, if false as an ASSOC array |
||
50 | * |
||
51 | * @return array() |
||
0 ignored issues
–
show
|
|||
52 | */ |
||
53 | 3 | final public function get($raw = true) { |
|
54 | |||
55 | 3 | if ( $raw === true ) return $this->completed_processes; |
|
56 | |||
57 | 3 | else return self::convert($this->completed_processes); |
|
58 | |||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Convert result into ASSOC array |
||
63 | * |
||
64 | * @param array $processes Array of process results |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 3 | private static function convert($processes) { |
|
69 | |||
70 | 3 | $assoc_processes = array(); |
|
71 | |||
72 | 3 | foreach ( $processes as $process ) { |
|
73 | |||
74 | 3 | array_push($assoc_processes, array( |
|
75 | 3 | 'pid' => $process[0], |
|
76 | 3 | 'name' => $process[1], |
|
77 | 3 | 'success'=> $process[2], |
|
78 | 3 | 'start' => $process[3], |
|
79 | 3 | 'end' => $process[4], |
|
80 | 3 | 'result' => $process[5], |
|
81 | 3 | 'id' => $process[6], |
|
82 | 3 | 'wid' => $process[7] |
|
83 | 3 | )); |
|
84 | |||
85 | 3 | } |
|
86 | |||
87 | 3 | return $assoc_processes; |
|
88 | |||
89 | } |
||
90 | |||
91 | } |
||
92 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.