public function __invoke(Id $id) { $query = new Query(['_id' => $id->value()]); $cursor = $this->mongo->executeQuery('booothy.photo', $query)->toArray(); if (empty($cursor)) { throw new NonExistingResource(); } return $this->hydrator->__invoke($cursor[0]); }
public static function generateNew($a_quote, $an_upload_mime_type, Email $an_email) { $id = Id::next(); $quote = new Quote($a_quote); $creation_date = new DateTimeImmutable(); $image_details = ImageDetails::fake(); $upload = self::generateUpload($a_quote, $creation_date, $an_upload_mime_type); return new self($id, $quote, $upload, $image_details, $creation_date, $an_email); }
public function __invoke(Id $id) { return $this->database_handler->getResource('photo', $id->value(), function () { throw new NonExistingResource(); }); }