Conditions | 5 |
Paths | 4 |
Total Lines | 29 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public function enrich(Document $doc) |
||
31 | { |
||
32 | \Log::debug('[GoogleBooksService] Checking document ' . $doc->id); |
||
|
|||
33 | |||
34 | $volume = $this->get($doc->bibliographic['isbns']); |
||
35 | |||
36 | // Delete old |
||
37 | $doc->enrichmentsByService(self::$serviceName) |
||
38 | ->delete(); |
||
39 | |||
40 | // Insert |
||
41 | $doc->enrichments()->create([ |
||
42 | 'document_version' => sha1(json_encode($doc->bibliographic)), |
||
43 | 'service_name' => self::$serviceName, |
||
44 | 'service_data' => $volume, |
||
45 | ]); |
||
46 | |||
47 | if ($volume) { |
||
48 | $cover_url = $volume->getCover(); |
||
49 | if (!is_null($cover_url) && is_null($doc->cover)) { |
||
50 | \Log::debug('[GoogleBooksService] Setting new cover to document #' . $doc->id); |
||
51 | try { |
||
52 | $doc->storeCover($cover_url); |
||
53 | } catch (\ErrorException $e) { |
||
54 | \Log::error('[GoogleBooksService] Failed to store cover: ' . $cover_url . "\n" . $e->getMessage()); |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.