@@ -21,7 +21,7 @@ |
||
21 | 21 | public static function getWebAccess($url = null) |
22 | 22 | { |
23 | 23 | // Local file |
24 | - if (! empty($url) && $url[0] === '/') { |
|
24 | + if (!empty($url) && $url[0] === '/') { |
|
25 | 25 | return new WebAccessLocal(); |
26 | 26 | } |
27 | 27 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Thumbnails image cache. |
28 | 28 | */ |
29 | - const TYPE_THUMB = 'thumb'; |
|
29 | + const TYPE_THUMB = 'thumb'; |
|
30 | 30 | /** |
31 | 31 | * Finder cache. |
32 | 32 | */ |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | self::rebuildCacheFolders(); |
57 | 57 | return self::getCachePath($type, true); |
58 | 58 | } else if (!$path) { |
59 | - throw new IOException('Cache folders are not writable: '. $cache); |
|
59 | + throw new IOException('Cache folders are not writable: '.$cache); |
|
60 | 60 | } |
61 | 61 | return $path; |
62 | 62 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | self::createDomainThumbCacheFolder($domain, $type); |
79 | 79 | $domainFolder = FileUtils::getPath(self::getCachePath($type), $domain); |
80 | 80 | if ($type === self::TYPE_THUMB) { |
81 | - $suffix = $width . $height . ($crop ? '1' : '0') .'.png'; |
|
81 | + $suffix = $width.$height.($crop ? '1' : '0').'.png'; |
|
82 | 82 | } else { |
83 | - $suffix = $width . $height; |
|
83 | + $suffix = $width.$height; |
|
84 | 84 | } |
85 | - return $domainFolder . self::getThumbFilename($url) . $suffix; |
|
85 | + return $domainFolder.self::getThumbFilename($url).$suffix; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public static function isCacheValid($cacheFile, $domain, $type) { |
101 | 101 | $out = false; |
102 | - $cacheDuration = ConfigManager::get('settings.cache_duration', 3600*24*31); |
|
102 | + $cacheDuration = ConfigManager::get('settings.cache_duration', 3600 * 24 * 31); |
|
103 | 103 | |
104 | 104 | if (is_readable($cacheFile) |
105 | 105 | && ($cacheDuration < 0 || (time() - filemtime($cacheFile)) < $cacheDuration) |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected static function createDomainThumbCacheFolder($domain, $type) |
122 | 122 | { |
123 | - $domainFolder = self::getCachePath($type) . $domain; |
|
123 | + $domainFolder = self::getCachePath($type).$domain; |
|
124 | 124 | if (!file_exists($domainFolder)) { |
125 | 125 | mkdir($domainFolder, 0775, false); |
126 | - touch($domainFolder . '/' . self::$CLEAN_FILE); |
|
126 | + touch($domainFolder.'/'.self::$CLEAN_FILE); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | protected static function checkCacheType($type) |
151 | 151 | { |
152 | 152 | if ($type != self::TYPE_THUMB && $type != self::TYPE_FINDER) { |
153 | - throw new CacheException('Unknown cache type '. $type); |
|
153 | + throw new CacheException('Unknown cache type '.$type); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | protected function replaceOption($thumbnailUrl, $option) |
59 | 59 | { |
60 | 60 | $chosenOption = $this->getOptionValue($option); |
61 | - return str_replace('${'. $option .'}', $chosenOption, $thumbnailUrl); |
|
61 | + return str_replace('${'.$option.'}', $chosenOption, $thumbnailUrl); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | protected function getOptionValue($option) |
73 | 73 | { |
74 | 74 | // If the provided option is not defined in the Finder rules. |
75 | - if (empty($this->finderOptions) || ! in_array($option, array_keys($this->finderOptions))) { |
|
76 | - throw new BadRulesException('Unknown option "'. $option .'" for the finder "'. $this->getName() .'"'); |
|
75 | + if (empty($this->finderOptions) || !in_array($option, array_keys($this->finderOptions))) { |
|
76 | + throw new BadRulesException('Unknown option "'.$option.'" for the finder "'.$this->getName().'"'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // User option is defined. |
80 | 80 | // Any defined option must provide a replacement value in rules under the `param` key. |
81 | - if (! empty($this->userOptions[$option]) |
|
81 | + if (!empty($this->userOptions[$option]) |
|
82 | 82 | && is_string($this->userOptions[$option]) |
83 | 83 | && isset($this->finderOptions[$option][$this->userOptions[$option]]['param']) |
84 | 84 | ) { |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | // If no user option has been found, and no default value is provided: error. |
90 | - if (! isset($this->finderOptions[$option]['default'])) { |
|
91 | - $error = 'No default set for option "'. $option .'" for the finder "'. $this->getName() .'"'; |
|
90 | + if (!isset($this->finderOptions[$option]['default'])) { |
|
91 | + $error = 'No default set for option "'.$option.'" for the finder "'.$this->getName().'"'; |
|
92 | 92 | throw new BadRulesException($error); |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Use default option replacement. |
96 | 96 | $default = $this->finderOptions[$option]['default']; |
97 | 97 | if (!isset($this->finderOptions[$option][$default]['param'])) { |
98 | - $error = 'No default parameter set for option "'. $option .'" for the finder "'. $this->getName() .'"'; |
|
98 | + $error = 'No default parameter set for option "'.$option.'" for the finder "'.$this->getName().'"'; |
|
99 | 99 | throw new BadRulesException($error); |
100 | 100 | } |
101 | 101 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function isHotlinkAllowed() |
109 | 109 | { |
110 | 110 | if ( |
111 | - ! isset($this->finderOptions['hotlink_allowed']) |
|
111 | + !isset($this->finderOptions['hotlink_allowed']) |
|
112 | 112 | || $this->finderOptions['hotlink_allowed'] === true |
113 | 113 | ) { |
114 | 114 | return true; |
@@ -62,16 +62,16 @@ discard block |
||
62 | 62 | return $this->url; |
63 | 63 | } |
64 | 64 | |
65 | - if (empty($thumbnail) && ! empty($headers) && strpos($headers[0], '200') === false) { |
|
65 | + if (empty($thumbnail) && !empty($headers) && strpos($headers[0], '200') === false) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | 69 | // With curl, the thumb is extracted during the download |
70 | - if ($this->webAccess instanceof WebAccessCUrl && ! empty($thumbnail)) { |
|
70 | + if ($this->webAccess instanceof WebAccessCUrl && !empty($thumbnail)) { |
|
71 | 71 | return $thumbnail; |
72 | 72 | } |
73 | 73 | |
74 | - return ! empty($content) ? self::extractMetaTag($content) : false; |
|
74 | + return !empty($content) ? self::extractMetaTag($content) : false; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | { |
145 | 145 | $propertiesKey = ['property', 'name', 'itemprop']; |
146 | 146 | // Try to retrieve OpenGraph image. |
147 | - $ogRegex = '#<meta[^>]+(?:'. implode('|', $propertiesKey) .')=["\']?og:image["\'\s][^>]*content=["\']?(.*?)["\'\s>]#'; |
|
147 | + $ogRegex = '#<meta[^>]+(?:'.implode('|', $propertiesKey).')=["\']?og:image["\'\s][^>]*content=["\']?(.*?)["\'\s>]#'; |
|
148 | 148 | // If the attributes are not in the order property => content (e.g. Github) |
149 | 149 | // New regex to keep this readable... more or less. |
150 | - $ogRegexReverse = '#<meta[^>]+content=["\']?([^"\'\s]+)[^>]+(?:'. implode('|', $propertiesKey) .')=["\']?og:image["\'\s/>]#'; |
|
150 | + $ogRegexReverse = '#<meta[^>]+content=["\']?([^"\'\s]+)[^>]+(?:'.implode('|', $propertiesKey).')=["\']?og:image["\'\s/>]#'; |
|
151 | 151 | |
152 | 152 | if (preg_match($ogRegex, $content, $matches) > 0 |
153 | 153 | || preg_match($ogRegexReverse, $content, $matches) > 0 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | // With curl, the thumb is extracted during the download |
91 | - if ($this->webAccess instanceof WebAccessCUrl && ! empty($thumbnail)) { |
|
91 | + if ($this->webAccess instanceof WebAccessCUrl && !empty($thumbnail)) { |
|
92 | 92 | return $thumbnail; |
93 | 93 | } |
94 | 94 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $thumbnailUrl = $this->thumbnailUrlFormat; |
154 | 154 | if (preg_match($this->urlRegex, $content, $matches) != false) { |
155 | 155 | for ($i = 1; $i < count($matches); $i++) { |
156 | - $thumbnailUrl = str_replace('${'. $i . '}', $matches[$i], $thumbnailUrl); |
|
156 | + $thumbnailUrl = str_replace('${'.$i.'}', $matches[$i], $thumbnailUrl); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Match only options (not ${number}) |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function checkRules($rules) |
174 | 174 | { |
175 | - if (! FinderUtils::checkMandatoryRules($rules, [ |
|
175 | + if (!FinderUtils::checkMandatoryRules($rules, [ |
|
176 | 176 | 'image_regex', |
177 | 177 | 'thumbnail_url' |
178 | 178 | ])) { |