Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
10 / 20 |
|
36.36% |
4 / 11 |
CRAP | |
0.00% |
0 / 1 |
| TaskLogCollection | |
50.00% |
10 / 20 |
|
36.36% |
4 / 11 |
38.50 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createFromArray | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| createEmptyCollection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIterator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isEmpty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| first | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| last | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIds | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoTaskQueue\model\TaskLog; |
| 23 | |
| 24 | use oat\taoTaskQueue\model\Entity\TaskLogEntity; |
| 25 | use oat\taoTaskQueue\model\Entity\TaskLogEntityInterface; |
| 26 | |
| 27 | /** |
| 28 | * @deprecated Use \oat\tao\model\taskQueue\TaskLog\TaskLogCollection |
| 29 | */ |
| 30 | class TaskLogCollection implements TaskLogCollectionInterface |
| 31 | { |
| 32 | /** @var TaskLogEntity[] */ |
| 33 | private $taskLogs = []; |
| 34 | |
| 35 | /** |
| 36 | * @param TaskLogEntity[] $taskLogs |
| 37 | */ |
| 38 | public function __construct(array $taskLogs) |
| 39 | { |
| 40 | $this->taskLogs = $taskLogs; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @param array $rows |
| 45 | * @return TaskLogCollection |
| 46 | * |
| 47 | * @throws \Exception |
| 48 | */ |
| 49 | public static function createFromArray(array $rows) |
| 50 | { |
| 51 | $logs = []; |
| 52 | |
| 53 | foreach ($rows as $row) { |
| 54 | $logs[] = TaskLogEntity::createFromArray($row); |
| 55 | } |
| 56 | |
| 57 | return new static($logs); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @return TaskLogCollection |
| 62 | */ |
| 63 | public static function createEmptyCollection() |
| 64 | { |
| 65 | return new static([]); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @inheritdoc |
| 70 | */ |
| 71 | public function jsonSerialize() |
| 72 | { |
| 73 | return $this->toArray(); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @return array |
| 78 | */ |
| 79 | public function toArray() |
| 80 | { |
| 81 | $data = []; |
| 82 | |
| 83 | foreach ($this->taskLogs as $taskLog) { |
| 84 | $data[] = $taskLog->toArray(); |
| 85 | } |
| 86 | |
| 87 | return $data; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return int |
| 92 | */ |
| 93 | public function count() |
| 94 | { |
| 95 | return count($this->taskLogs); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @return \ArrayIterator |
| 100 | */ |
| 101 | public function getIterator() |
| 102 | { |
| 103 | return new \ArrayIterator($this->taskLogs); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @return bool |
| 108 | */ |
| 109 | public function isEmpty() |
| 110 | { |
| 111 | return empty($this->taskLogs); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @return TaskLogEntity |
| 116 | */ |
| 117 | public function first() |
| 118 | { |
| 119 | return reset($this->taskLogs); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * @return TaskLogEntity |
| 124 | */ |
| 125 | public function last() |
| 126 | { |
| 127 | return end($this->taskLogs); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * @inheritdoc |
| 132 | */ |
| 133 | public function getIds() |
| 134 | { |
| 135 | $ids = []; |
| 136 | /** @var TaskLogEntityInterface $item */ |
| 137 | foreach ($this->taskLogs as $item) { |
| 138 | $ids[] = $item->getId(); |
| 139 | } |
| 140 | |
| 141 | return $ids; |
| 142 | } |
| 143 | } |