document = $document; return $this; } /** * Document's body as fetched by Cyca. * * @param string $body * * @return self */ public function setBody($body) { $this->body = $body; return $this; } /** * HTTP response when fetching document. * * @return self */ public function setResponse(Response $response) { $this->response = $response; return $this; } /** * Store details on disk. */ protected function storeDetailsOnDisk() { if (empty($this->details)) { return; } $storageRoot = $this->document->getStoragePath(); $metaFilename = sprintf('%s/meta.json', $storageRoot); Storage::put($metaFilename, json_encode($this->details)); } /** * Store some details in database. This method uses an array to map document * properties to metadata properties. * * @param array $mappings */ protected function applyDetailsToDocument($mappings = []) { foreach ($mappings as $documentKey => $detailsKey) { if (!empty($this->details[$detailsKey])) { $this->document->{$documentKey} = $this->details[$detailsKey]; } } } }