json_encode($configuration) ]; $job = $this->jobRepository->create($data); return $this->process($this->jobRepository->save($job)); } catch (PDOException $exception) { throw new Create(__CLASS__, $exception); } } /** * @return array * @throws Read */ public function getPending(): array { try { return array_map([$this, 'process'],$this->jobRepository->fetchPending()); } catch (EmptyResult $exception) { throw new Read(__CLASS__, $exception); } } /** * @param Model\Job $job * @return bool * @throws Update */ public function execute(Model\Job $job): bool { try { $this->jobRepository->edit($job, ['executed' => true]); return true; } catch (EmptyResult | PDOException $exception) { throw new Update(__CLASS__, $exception); } } protected function process(Model\Job $job): Model\Job { return $job; } }