$taskIds * * @throws TaskNotBookable * @throws TimeLocked */ public function pin(int $userId, array $taskIds): void { $now = $this->clock->now(); $this->transactions->run(function () use ($userId, $taskIds, $now): void { foreach ($taskIds as $taskId) { $task = $this->tasks->bookableTask($taskId) ?? throw new TaskNotBookable($taskId); if ($task->isLocked()) { throw new TimeLocked; } $this->pins->pin($userId, $taskId, $now); } }); } public function unpin(int $userId, int $taskId): void { $this->transactions->run(fn () => $this->pins->unpin($userId, $taskId)); } /** * "Poista kaikki kiinnitykset". */ public function unpinAll(int $userId): int { return $this->transactions->run(fn (): int => $this->pins->unpinAll($userId)); } }