addType('id', 'integer'); $this->addType('lastUpdated', 'integer'); $this->addType('type', 'string'); $this->addType('input', 'string'); $this->addType('output', 'string'); $this->addType('status', 'integer'); $this->addType('userId', 'string'); $this->addType('appId', 'string'); $this->addType('identifier', 'string'); $this->addType('completionExpectedAt', 'datetime'); } public function toRow(): array { return array_combine(self::$columns, array_map(function ($field) { return $this->{'get'.ucfirst($field)}(); }, self::$fields)); } public static function fromPublicTask(OCPTask $task): Task { /** @var Task $task */ $task = Task::fromParams([ 'id' => $task->getId(), 'type' => $task->getType(), 'lastUpdated' => time(), 'status' => $task->getStatus(), 'input' => $task->getInput(), 'output' => $task->getOutput(), 'userId' => $task->getUserId(), 'appId' => $task->getAppId(), 'identifier' => $task->getIdentifier(), 'completionExpectedAt' => $task->getCompletionExpectedAt(), ]); return $task; } public function toPublicTask(): OCPTask { $task = new OCPTask($this->getType(), $this->getInput(), $this->getAppId(), $this->getuserId(), $this->getIdentifier()); $task->setId($this->getId()); $task->setStatus($this->getStatus()); $task->setOutput($this->getOutput()); $task->setCompletionExpectedAt($this->getCompletionExpectedAt()); return $task; } }