@@ -60,6 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Get enrichments associated with this document. |
| 63 | + * @param string $serviceName |
|
| 63 | 64 | */ |
| 64 | 65 | public function enrichmentsByService($serviceName) |
| 65 | 66 | { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace Colligator; |
| 4 | 4 | |
| 5 | 5 | use Scriptotek\GoogleBooks\GoogleBooks; |
| 6 | -use Scriptotek\GoogleBooks\Exceptions\UsageRateExceeded; |
|
| 7 | 6 | |
| 8 | 7 | class GoogleBooksService implements EnrichmentService |
| 9 | 8 | { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | foreach ($isbns as $isbn) { |
| 21 | 21 | $volume = $this->books->volumes->byIsbn($isbn); |
| 22 | - \Log::debug('[GoogleBooksService] - ' . $isbn . ': ' . (is_null($volume) ? 'not found' : 'found')); |
|
| 22 | + \Log::debug('[GoogleBooksService] - '.$isbn.': '.(is_null($volume) ? 'not found' : 'found')); |
|
| 23 | 23 | if (!is_null($volume)) { |
| 24 | 24 | return $volume; |
| 25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function enrich(Document $doc) |
| 31 | 31 | { |
| 32 | - \Log::debug('[GoogleBooksService] Checking document ' . $doc->id); |
|
| 32 | + \Log::debug('[GoogleBooksService] Checking document '.$doc->id); |
|
| 33 | 33 | |
| 34 | 34 | $volume = $this->get($doc->bibliographic['isbns']); |
| 35 | 35 | |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | if ($volume) { |
| 48 | 48 | $cover_url = $volume->getCover(); |
| 49 | 49 | if (!is_null($cover_url) && is_null($doc->cover)) { |
| 50 | - \Log::debug('[GoogleBooksService] Setting new cover to document #' . $doc->id); |
|
| 50 | + \Log::debug('[GoogleBooksService] Setting new cover to document #'.$doc->id); |
|
| 51 | 51 | try { |
| 52 | 52 | $doc->storeCover($cover_url); |
| 53 | 53 | } catch (\ErrorException $e) { |
| 54 | - \Log::error('[GoogleBooksService] Failed to store cover: ' . $cover_url . "\n" . $e->getMessage()); |
|
| 54 | + \Log::error('[GoogleBooksService] Failed to store cover: '.$cover_url."\n".$e->getMessage()); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public function handleDocuments(EnrichmentService $service, $docs) |
| 73 | 73 | { |
| 74 | - \Log::info('[EnrichDocuments] Starting job. ' . count($docs) . ' documents to be checked using the "' . $service::$serviceName . '" service.'); |
|
| 74 | + \Log::info('[EnrichDocuments] Starting job. '.count($docs).' documents to be checked using the "'.$service::$serviceName.'" service.'); |
|
| 75 | 75 | |
| 76 | 76 | // $this->output->progressStart(count($docs)); |
| 77 | 77 | foreach ($docs as $doc) { |
@@ -107,22 +107,22 @@ discard block |
||
| 107 | 107 | $collectionId = intval($this->option('collection')); |
| 108 | 108 | |
| 109 | 109 | if (!isset($this->services[$serviceName])) { |
| 110 | - $this->error('Service "' . $serviceName . '" is not defined. Available servies: "' . implode('", "', array_keys($this->services)) . '".'); |
|
| 110 | + $this->error('Service "'.$serviceName.'" is not defined. Available servies: "'.implode('", "', array_keys($this->services)).'".'); |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if ($verbose) { |
| 115 | - \DB::listen(function ($query, $bindings) { |
|
| 116 | - $this->comment('Query: ' . $query . '. Bindings: ' . implode(', ', $bindings)); |
|
| 115 | + \DB::listen(function($query, $bindings) { |
|
| 116 | + $this->comment('Query: '.$query.'. Bindings: '.implode(', ', $bindings)); |
|
| 117 | 117 | }); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $collectionHelp = ($collectionId > 0) ? ' in collection ' . $collectionId : ''; |
|
| 120 | + $collectionHelp = ($collectionId > 0) ? ' in collection '.$collectionId : ''; |
|
| 121 | 121 | |
| 122 | 122 | $docs = $this->getDocumentsToBeChecked($serviceName, $force, $collectionId); |
| 123 | 123 | |
| 124 | 124 | if (!count($docs)) { |
| 125 | - $this->info('No new documents' . $collectionHelp . '. Exiting.'); |
|
| 125 | + $this->info('No new documents'.$collectionHelp.'. Exiting.'); |
|
| 126 | 126 | \Log::info('[EnrichDocuments] No new documents to be checked.'); |
| 127 | 127 | return; |
| 128 | 128 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function invalidateCache() |
| 79 | 79 | { |
| 80 | 80 | if (!is_null($this->width) && !is_null($this->height)) { |
| 81 | - \Log::debug('[Cover] Invalidating cache. Old version was ' . $this->width . ' x ' . $this->height); |
|
| 81 | + \Log::debug('[Cover] Invalidating cache. Old version was '.$this->width.' x '.$this->height); |
|
| 82 | 82 | } |
| 83 | 83 | $this->width = null; |
| 84 | 84 | $this->height = null; |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | throw new \ErrorException('[Cover] Cannot cache when no URL set.'); |
| 124 | 124 | } |
| 125 | 125 | if ($this->isCached()) { |
| 126 | - \Log::debug('[Cover] Already cached: ' . $this->url); |
|
| 126 | + \Log::debug('[Cover] Already cached: '.$this->url); |
|
| 127 | 127 | |
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - \Log::debug('[Cover] Add to cache: ' . $this->url); |
|
| 131 | + \Log::debug('[Cover] Add to cache: '.$this->url); |
|
| 132 | 132 | |
| 133 | 133 | $orig = \CoverCache::put($this->url); |
| 134 | 134 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | /* |
| 20 | 20 | * Authenticate the user's personal channel... |
| 21 | 21 | */ |
| 22 | - Broadcast::channel('Colligator.User.{userId}', function ($user, $userId) { |
|
| 22 | + Broadcast::channel('Colligator.User.{userId}', function($user, $userId) { |
|
| 23 | 23 | return (int) $user->id === (int) $userId; |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | Route::group([ |
| 42 | 42 | 'middleware' => 'web', |
| 43 | 43 | 'namespace' => $this->namespace, |
| 44 | - ], function () { |
|
| 44 | + ], function() { |
|
| 45 | 45 | require base_path('routes/web.php'); |
| 46 | 46 | }); |
| 47 | 47 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'middleware' => 'api', |
| 59 | 59 | 'namespace' => $this->namespace, |
| 60 | 60 | // 'prefix' => 'api', |
| 61 | - ], function () { |
|
| 61 | + ], function() { |
|
| 62 | 62 | require base_path('routes/api.php'); |
| 63 | 63 | }); |
| 64 | 64 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $this->imageManager = $imageManager ?: app('Intervention\Image\ImageManager'); |
| 22 | 22 | $maxAge = 3153600; // 30 days |
| 23 | 23 | $this->fsConfig = new FlysystemConfig([ |
| 24 | - 'CacheControl' => 'max-age=' . $maxAge . ', public', |
|
| 24 | + 'CacheControl' => 'max-age='.$maxAge.', public', |
|
| 25 | 25 | ]); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function basename() |
| 71 | 71 | { |
| 72 | - return sha1($this->sourceUrl . $this->maxHeight); |
|
| 72 | + return sha1($this->sourceUrl.$this->maxHeight); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -95,28 +95,28 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $data = $this->download(); |
| 97 | 97 | if (!$data) { |
| 98 | - throw new \ErrorException('[CoverCache] Failed to download ' . $this->sourceUrl); |
|
| 98 | + throw new \ErrorException('[CoverCache] Failed to download '.$this->sourceUrl); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $img = $this->imageManager->make($data); |
| 102 | 102 | if ($this->maxHeight && $img->height() > $this->maxHeight) { |
| 103 | - \Log::debug('[CachedImage] Resizing from ' . $img->height() . ' to ' . $this->maxHeight); |
|
| 103 | + \Log::debug('[CachedImage] Resizing from '.$img->height().' to '.$this->maxHeight); |
|
| 104 | 104 | $img->heighten($this->maxHeight); |
| 105 | 105 | $data = strval($img->encode('jpg')); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if ($img->width() / $img->height() > 1.4) { |
| 109 | - throw new \ErrorException('[CoverCache] Not accepting images with w/h ratio > 1.4: ' . $this->sourceUrl); |
|
| 109 | + throw new \ErrorException('[CoverCache] Not accepting images with w/h ratio > 1.4: '.$this->sourceUrl); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $this->setMetadata($data, $img); |
| 113 | 113 | |
| 114 | - \Log::debug('[CachedImage] Storing image as ' . $img->width() . ' x ' . $img->height() . ', ' . strlen($data) . ' bytes'); |
|
| 114 | + \Log::debug('[CachedImage] Storing image as '.$img->width().' x '.$img->height().', '.strlen($data).' bytes'); |
|
| 115 | 115 | if (!$this->filesystem->write($this->basename(), $data, $this->fsConfig)) { |
| 116 | - throw new \ErrorException('[CoverCache] Failed to upload to S3: ' . $this->sourceUrl); |
|
| 116 | + throw new \ErrorException('[CoverCache] Failed to upload to S3: '.$this->sourceUrl); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - \Log::debug('[CachedImage] Wrote cached version of ' . $this->sourceUrl . ' as ' . $this->basename()); |
|
| 119 | + \Log::debug('[CachedImage] Wrote cached version of '.$this->sourceUrl.' as '.$this->basename()); |
|
| 120 | 120 | |
| 121 | 121 | return $this; |
| 122 | 122 | } |