addType('id', Types::INTEGER); $this->addType('userId', Types::STRING); $this->addType('title', Types::STRING); $this->addType('boardId', Types::INTEGER); $this->addType('sourceStackId', Types::INTEGER); $this->addType('targetStackId', Types::INTEGER); $this->addType('filterUserIds', Types::STRING); $this->addType('filterLabelIds', Types::STRING); $this->addType('notifyEmail', Types::BOOLEAN); $this->addType('enabled', Types::BOOLEAN); $this->addType('lastRun', Types::DATETIME); } /** * @return string[] */ public function getFilterUserIdsArray(): array { return $this->decodeIds($this->getFilterUserIds()); } /** * @return int[] */ public function getFilterLabelIdsArray(): array { return array_map('intval', $this->decodeIds($this->getFilterLabelIds())); } /** * @return string[] */ private function decodeIds(?string $json): array { if ($json === null || $json === '') { return []; } $decoded = json_decode($json, true); return is_array($decoded) ? array_values($decoded) : []; } public function jsonSerialize(): array { return [ 'id' => $this->getId(), 'userId' => $this->getUserId(), 'title' => $this->getTitle(), 'boardId' => $this->getBoardId(), 'sourceStackId' => $this->getSourceStackId(), 'targetStackId' => $this->getTargetStackId(), 'filterUserIds' => $this->getFilterUserIdsArray(), 'filterLabelIds' => $this->getFilterLabelIdsArray(), 'notifyEmail' => (bool)$this->getNotifyEmail(), 'enabled' => (bool)$this->getEnabled(), 'lastRun' => $this->getLastRun()?->format(\DateTimeInterface::ATOM), ]; } }