taskLogs = $taskLogs; } /** * @param array $rows * @return TaskLogCollection * * @throws \Exception */ public static function createFromArray(array $rows) { $logs = []; foreach ($rows as $row) { $logs[] = TaskLogEntity::createFromArray($row); } return new static($logs); } /** * @return TaskLogCollection */ public static function createEmptyCollection() { return new static([]); } /** * @inheritdoc */ public function jsonSerialize() { return $this->toArray(); } /** * @return array */ public function toArray() { $data = []; foreach ($this->taskLogs as $taskLog) { $data[] = $taskLog->toArray(); } return $data; } /** * @return int */ public function count() { return count($this->taskLogs); } /** * @return \ArrayIterator */ public function getIterator() { return new \ArrayIterator($this->taskLogs); } /** * @return bool */ public function isEmpty() { return empty($this->taskLogs); } /** * @return TaskLogEntity */ public function first() { return reset($this->taskLogs); } /** * @return TaskLogEntity */ public function last() { return end($this->taskLogs); } /** * @inheritdoc */ public function getIds() { $ids = []; /** @var TaskLogEntityInterface $item */ foreach ($this->taskLogs as $item) { $ids[] = $item->getId(); } return $ids; } }