@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | /** |
| 70 | 70 | * @param string $url |
| 71 | 71 | * |
| 72 | - * @return integer |
|
| 72 | + * @return boolean |
|
| 73 | 73 | */ |
| 74 | 74 | public function shouldBlock($url) |
| 75 | 75 | { |
@@ -118,7 +118,6 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * Set external resources cache expire (in days) |
| 120 | 120 | * |
| 121 | - * @param integer $expire |
|
| 122 | 121 | */ |
| 123 | 122 | public function setCacheExpire($expireInDays) |
| 124 | 123 | { |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | private $cacheExpire = 1; // 1 day |
| 9 | 9 | |
| 10 | - const CACHE_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR; |
|
| 10 | + const CACHE_FOLDER = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR; |
|
| 11 | 11 | |
| 12 | - public function __construct($rules = []) |
|
| 12 | + public function __construct($rules = [ ]) |
|
| 13 | 13 | { |
| 14 | - $this->rules = []; |
|
| 14 | + $this->rules = [ ]; |
|
| 15 | 15 | $this->addRules($rules); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | foreach ($rules as $rule) { |
| 24 | 24 | try { |
| 25 | - $this->rules[] = new AdblockRule($rule); |
|
| 25 | + $this->rules[ ] = new AdblockRule($rule); |
|
| 26 | 26 | } catch (InvalidRuleException $e) { |
| 27 | 27 | // Skip invalid rules |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Sort rules, eceptions first |
| 32 | - usort($this->rules, function ($a, $b) { |
|
| 33 | - return (int)$a->isException() < (int)$b->isException(); |
|
| 32 | + usort($this->rules, function($a, $b) { |
|
| 33 | + return (int) $a->isException() < (int) $b->isException(); |
|
| 34 | 34 | }); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function clearCache() |
| 132 | 132 | { |
| 133 | - foreach (glob(self::CACHE_FOLDER . '*') as $file) { |
|
| 133 | + foreach (glob(self::CACHE_FOLDER.'*') as $file) { |
|
| 134 | 134 | unlink($file); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function getCachedResource($url) |
| 144 | 144 | { |
| 145 | - $cacheFile = self::CACHE_FOLDER . basename($url) . md5($url); |
|
| 145 | + $cacheFile = self::CACHE_FOLDER.basename($url).md5($url); |
|
| 146 | 146 | |
| 147 | 147 | if (file_exists($cacheFile) && (filemtime($cacheFile) > (time() - 60 * 24 * $this->cacheExpire))) { |
| 148 | 148 | // Cache file is less than five minutes old. |