@@ -13,6 +13,9 @@ |
||
13 | 13 | public $maxHeight; |
14 | 14 | protected $_metadata; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string|null $url |
|
18 | + */ |
|
16 | 19 | public function __construct($url, $maxHeight = 0, AdapterInterface $filesystem = null, ImageManager $imageManager = null) |
17 | 20 | { |
18 | 21 | $this->sourceUrl = $url; |
@@ -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 | /** |
@@ -97,28 +97,28 @@ discard block |
||
97 | 97 | $data = $this->download(); |
98 | 98 | } |
99 | 99 | if (!$data) { |
100 | - throw new \ErrorException('[CoverCache] Failed to download ' . $this->sourceUrl); |
|
100 | + throw new \ErrorException('[CoverCache] Failed to download '.$this->sourceUrl); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $img = $this->imageManager->make($data); |
104 | 104 | if ($this->maxHeight && $img->height() > $this->maxHeight) { |
105 | - \Log::debug('[CachedImage] Resizing from ' . $img->height() . ' to ' . $this->maxHeight); |
|
105 | + \Log::debug('[CachedImage] Resizing from '.$img->height().' to '.$this->maxHeight); |
|
106 | 106 | $img->heighten($this->maxHeight); |
107 | 107 | $data = strval($img->encode('jpg')); |
108 | 108 | } |
109 | 109 | |
110 | 110 | if ($img->width() / $img->height() > 1.4) { |
111 | - throw new \ErrorException('[CoverCache] Not accepting images with w/h ratio > 1.4: ' . $this->sourceUrl); |
|
111 | + throw new \ErrorException('[CoverCache] Not accepting images with w/h ratio > 1.4: '.$this->sourceUrl); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $this->setMetadata($data, $img); |
115 | 115 | |
116 | - \Log::debug('[CachedImage] Storing image as ' . $img->width() . ' x ' . $img->height() . ', ' . strlen($data) . ' bytes'); |
|
116 | + \Log::debug('[CachedImage] Storing image as '.$img->width().' x '.$img->height().', '.strlen($data).' bytes'); |
|
117 | 117 | if (!$this->filesystem->write($this->basename(), $data, $this->fsConfig)) { |
118 | - throw new \ErrorException('[CoverCache] Failed to upload to S3: ' . $this->sourceUrl); |
|
118 | + throw new \ErrorException('[CoverCache] Failed to upload to S3: '.$this->sourceUrl); |
|
119 | 119 | } |
120 | 120 | |
121 | - \Log::debug('[CachedImage] Wrote cached version of ' . $this->sourceUrl . ' as ' . $this->basename()); |
|
121 | + \Log::debug('[CachedImage] Wrote cached version of '.$this->sourceUrl.' as '.$this->basename()); |
|
122 | 122 | |
123 | 123 | return $this; |
124 | 124 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | $cover = $doc->storeCoverFromBlob($data); |
170 | 170 | } |
171 | 171 | } catch (\ErrorException $e) { |
172 | - \Log::error('Failed to cache cover ' . $request->url . '. Got error: ' . $e->getMessage()); |
|
172 | + \Log::error('Failed to cache cover '.$request->url.'. Got error: '.$e->getMessage()); |
|
173 | 173 | |
174 | 174 | return response()->json([ |
175 | 175 | 'result' => 'error', |
176 | - 'error' => 'Failed to store the cover. Please check that the URL points to a valid image file. Details: ' . $e->getMessage(), |
|
176 | + 'error' => 'Failed to store the cover. Please check that the URL points to a valid image file. Details: '.$e->getMessage(), |
|
177 | 177 | ]); |
178 | 178 | } |
179 | 179 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ]; |
209 | 209 | $doc->save(); |
210 | 210 | |
211 | - \Log::info('Stored new description for ' . $doc->id); |
|
211 | + \Log::info('Stored new description for '.$doc->id); |
|
212 | 212 | |
213 | 213 | $se->indexById($doc->id); |
214 | 214 |
@@ -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; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $orig = \CoverCache::putBlob($blob); |
134 | 134 | |
135 | 135 | } else { |
136 | - \Log::debug('[Cover] Add to cache from url: ' . $this->url); |
|
136 | + \Log::debug('[Cover] Add to cache from url: '.$this->url); |
|
137 | 137 | $orig = \CoverCache::putUrl($this->url); |
138 | 138 | } |
139 | 139 |