Completed
Push — master ( b1fc83...ef90de )
by Arthur
10s
created
src/WebThumbnailer/Utils/UrlUtils.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public static function getDomain($url)
22 22
     {
23
-        if (! parse_url($url, PHP_URL_SCHEME)) {
24
-            $url = 'http://' . $url;
23
+        if (!parse_url($url, PHP_URL_SCHEME)) {
24
+            $url = 'http://'.$url;
25 25
         }
26 26
         return strtolower(parse_url($url, PHP_URL_HOST));
27 27
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public static function generateRelativeUrlFromPath($server, $path)
42 42
     {
43 43
         if (isset($server['DOCUMENT_ROOT'])) {
44
-            $root = ! empty($server['DOCUMENT_ROOT']) ? rtrim($server['DOCUMENT_ROOT'], '/') .'/' : '';
44
+            $root = !empty($server['DOCUMENT_ROOT']) ? rtrim($server['DOCUMENT_ROOT'], '/').'/' : '';
45 45
             return substr($path, strlen($root));
46 46
         }
47 47
         return $path;
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/FinderUtils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public static function buildRegex($regex, $flags)
26 26
     {
27
-        return '{' . $regex . '}' . $flags;
27
+        return '{'.$regex.'}'.$flags;
28 28
     }
29 29
 
30 30
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                     return false;
47 47
                 }
48 48
             } else {
49
-                if (! isset($rules[$value])) {
49
+                if (!isset($rules[$value])) {
50 50
                     return false;
51 51
                 }
52 52
             }
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/ImageUtils.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function generateThumbnail($imageStr, $target, $maxWidth, $maxHeight, $crop = false)
34 34
     {
35
-        if (! touch($target)) {
35
+        if (!touch($target)) {
36 36
             throw new ImageConvertException('Target file is not writable.');
37 37
         }
38 38
 
39
-        if ($crop && ($maxWidth == 0  || $maxHeight == 0)) {
39
+        if ($crop && ($maxWidth == 0 || $maxHeight == 0)) {
40 40
             throw new ImageConvertException('Both width and height must be provided for cropping');
41 41
         }
42 42
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         );
64 64
 
65 65
         $targetImg = imagecreatetruecolor($finalWidth, $finalHeight);
66
-        if (! imagecopyresized(
66
+        if (!imagecopyresized(
67 67
                 $targetImg, $sourceImg,
68 68
                 0, 0, 0, 0,
69 69
                 $finalWidth, $finalHeight, $originalWidth, $originalHeight
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $diffHeight = !empty($maxHeight) ? $originalHeight - $maxHeight : false;
98 98
 
99 99
         if (($diffHeight === false && $diffWidth !== false)
100
-            || ($diffWidth > $diffHeight && ! $crop)
100
+            || ($diffWidth > $diffHeight && !$crop)
101 101
             || ($diffWidth < $diffHeight && $crop)
102 102
         ) {
103 103
             $finalWidth = $maxWidth;
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/DataUtils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
      */
27 27
     public static function loadJson($jsonFile)
28 28
     {
29
-        if (! file_exists($jsonFile) || ! is_readable($jsonFile)) {
29
+        if (!file_exists($jsonFile) || !is_readable($jsonFile)) {
30 30
             throw new IOException('JSON resource file not found or not readable.');
31 31
         }
32 32
         $data = json_decode(file_get_contents($jsonFile), true);
33 33
         if ($data === null) {
34 34
             $error = json_last_error();
35 35
             $msg = json_last_error_msg();
36
-            throw new BadRulesException('An error occured while parsing JSON file: error code #'. $error .': '. $msg);
36
+            throw new BadRulesException('An error occured while parsing JSON file: error code #'.$error.': '.$msg);
37 37
         }
38 38
         return $data;
39 39
     }
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/SizeUtils.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
      */
51 51
     public static function isMetaSize($size)
52 52
     {
53
-        $metaSize = array (
53
+        $metaSize = array(
54 54
             WebThumbnailer::SIZE_SMALL,
55 55
             WebThumbnailer::SIZE_MEDIUM,
56 56
             WebThumbnailer::SIZE_LARGE
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/FileUtils.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@
 block discarded – undo
51 51
 
52 52
         foreach (
53 53
             new \RecursiveIteratorIterator(
54
-                 new \RecursiveDirectoryIterator(
55
-                     $path,
56
-                     \FilesystemIterator::SKIP_DOTS |
57
-                     \FilesystemIterator::UNIX_PATHS
58
-                 ),
59
-                 \RecursiveIteratorIterator::CHILD_FIRST
54
+                    new \RecursiveDirectoryIterator(
55
+                        $path,
56
+                        \FilesystemIterator::SKIP_DOTS |
57
+                        \FilesystemIterator::UNIX_PATHS
58
+                    ),
59
+                    \RecursiveIteratorIterator::CHILD_FIRST
60 60
             )
61 61
             as $value
62 62
         ) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @var string Path to resources folder.
14 14
      */
15
-    const RESOURCES_PATH = __DIR__ . DIRECTORY_SEPARATOR .'..'. DIRECTORY_SEPARATOR .'resources'. DIRECTORY_SEPARATOR;
15
+    const RESOURCES_PATH = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR;
16 16
 
17 17
     /**
18 18
      * Build the real path from all given folders, with a trailing /.
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
         if ($nbArgs == 0) {
30 30
             return false;
31 31
         }
32
-        for($i = 0; $i < $nbArgs; $i++) {
33
-            $out .= rtrim(rtrim(func_get_arg($i), '/'), '\\') . DIRECTORY_SEPARATOR;
32
+        for ($i = 0; $i < $nbArgs; $i++) {
33
+            $out .= rtrim(rtrim(func_get_arg($i), '/'), '\\').DIRECTORY_SEPARATOR;
34 34
         }
35 35
         $out = realpath($out);
36
-        return $out != false ? $out . DIRECTORY_SEPARATOR : false;
36
+        return $out != false ? $out.DIRECTORY_SEPARATOR : false;
37 37
     }
38 38
 
39 39
     /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public static function rmdir($path)
47 47
     {
48
-        if (empty($path) || $path == '/' || ! self::getPath($path)) {
48
+        if (empty($path) || $path == '/' || !self::getPath($path)) {
49 49
             return false;
50 50
         }
51 51
 
Please login to merge, or discard this patch.
src/WebThumbnailer/Utils/ApplicationUtils.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     public static function checkExtensionRequirements($required)
17 17
     {
18 18
         foreach ($required as $extension) {
19
-            if (! extension_loaded($extension)) {
19
+            if (!extension_loaded($extension)) {
20 20
                 throw new MissingRequirementException(sprintf(
21 21
                     'PHP extension php-%s is required and must be loaded',
22 22
                     $extension
Please login to merge, or discard this patch.
src/WebThumbnailer/Application/WebAccess/WebAccessFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/WebThumbnailer/Application/CacheManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.