Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| TaskFactory | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| build | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 | |||
| 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\Task; |
| 23 | |
| 24 | /** |
| 25 | * @deprecated Use \oat\tao\model\taskQueue\Task\TaskFactory |
| 26 | */ |
| 27 | class TaskFactory |
| 28 | { |
| 29 | /** |
| 30 | * @param array $basicData |
| 31 | * |
| 32 | * @return TaskInterface |
| 33 | * @throws InvalidTaskException |
| 34 | */ |
| 35 | public static function build($basicData) |
| 36 | { |
| 37 | $className = $basicData[TaskInterface::JSON_TASK_CLASS_NAME_KEY]; |
| 38 | |
| 39 | if (class_exists($className) && is_subclass_of($className, TaskInterface::class)) { |
| 40 | $metaData = $basicData[TaskInterface::JSON_METADATA_KEY]; |
| 41 | |
| 42 | /** @var TaskInterface $task */ |
| 43 | $task = new $className( |
| 44 | $metaData[TaskInterface::JSON_METADATA_ID_KEY], |
| 45 | $metaData[TaskInterface::JSON_METADATA_OWNER_KEY] |
| 46 | ); |
| 47 | $task->setMetadata($metaData); |
| 48 | $task->setParameter($basicData[TaskInterface::JSON_PARAMETERS_KEY]); |
| 49 | |
| 50 | if (isset($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])) { |
| 51 | $task->setCreatedAt(new \DateTime($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])); |
| 52 | } |
| 53 | |
| 54 | return $task; |
| 55 | } |
| 56 | |
| 57 | throw new InvalidTaskException(); |
| 58 | } |
| 59 | } |