Passed
Push — master ( cd72be...c5a016 )
by Joas
17:27 queued 03:51
created
lib/private/Preview/ProviderV2.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 	/**
44 44
 	 * @return string Regex with the mimetypes that are supported by this provider
45 45
 	 */
46
-	abstract public function getMimeType(): string ;
46
+	abstract public function getMimeType(): string;
47 47
 
48 48
 	/**
49 49
 	 * Check if a preview can be generated for $path
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -31,89 +31,89 @@
 block discarded – undo
31 31
 use OCP\Preview\IProviderV2;
32 32
 
33 33
 abstract class ProviderV2 implements IProviderV2 {
34
-	/** @var array */
35
-	protected $options;
36
-
37
-	/** @var array */
38
-	protected $tmpFiles = [];
39
-
40
-	/**
41
-	 * Constructor
42
-	 *
43
-	 * @param array $options
44
-	 */
45
-	public function __construct(array $options = []) {
46
-		$this->options = $options;
47
-	}
48
-
49
-	/**
50
-	 * @return string Regex with the mimetypes that are supported by this provider
51
-	 */
52
-	abstract public function getMimeType(): string ;
53
-
54
-	/**
55
-	 * Check if a preview can be generated for $path
56
-	 *
57
-	 * @param FileInfo $file
58
-	 * @return bool
59
-	 */
60
-	public function isAvailable(FileInfo $file): bool {
61
-		return true;
62
-	}
63
-
64
-	/**
65
-	 * get thumbnail for file at path $path
66
-	 *
67
-	 * @param File $file
68
-	 * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
69
-	 * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
70
-	 * @return null|\OCP\IImage false if no preview was generated
71
-	 * @since 17.0.0
72
-	 */
73
-	abstract public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage;
74
-
75
-	protected function useTempFile(File $file): bool {
76
-		return $file->isEncrypted() || !$file->getStorage()->isLocal();
77
-	}
78
-
79
-	/**
80
-	 * Get a path to either the local file or temporary file
81
-	 *
82
-	 * @param File $file
83
-	 * @param int $maxSize maximum size for temporary files
84
-	 * @return string|false
85
-	 */
86
-	protected function getLocalFile(File $file, int $maxSize = null) {
87
-		if ($this->useTempFile($file)) {
88
-			$absPath = \OC::$server->getTempManager()->getTemporaryFile();
89
-
90
-			$content = $file->fopen('r');
91
-
92
-			if ($maxSize) {
93
-				$content = stream_get_contents($content, $maxSize);
94
-			}
95
-
96
-			file_put_contents($absPath, $content);
97
-			$this->tmpFiles[] = $absPath;
98
-			return $absPath;
99
-		} else {
100
-			$path = $file->getStorage()->getLocalFile($file->getInternalPath());
101
-			if (is_string($path)) {
102
-				return $path;
103
-			} else {
104
-				return false;
105
-			}
106
-		}
107
-	}
108
-
109
-	/**
110
-	 * Clean any generated temporary files
111
-	 */
112
-	protected function cleanTmpFiles(): void {
113
-		foreach ($this->tmpFiles as $tmpFile) {
114
-			unlink($tmpFile);
115
-		}
116
-
117
-		$this->tmpFiles = [];
118
-	}
34
+    /** @var array */
35
+    protected $options;
36
+
37
+    /** @var array */
38
+    protected $tmpFiles = [];
39
+
40
+    /**
41
+     * Constructor
42
+     *
43
+     * @param array $options
44
+     */
45
+    public function __construct(array $options = []) {
46
+        $this->options = $options;
47
+    }
48
+
49
+    /**
50
+     * @return string Regex with the mimetypes that are supported by this provider
51
+     */
52
+    abstract public function getMimeType(): string ;
53
+
54
+    /**
55
+     * Check if a preview can be generated for $path
56
+     *
57
+     * @param FileInfo $file
58
+     * @return bool
59
+     */
60
+    public function isAvailable(FileInfo $file): bool {
61
+        return true;
62
+    }
63
+
64
+    /**
65
+     * get thumbnail for file at path $path
66
+     *
67
+     * @param File $file
68
+     * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
69
+     * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
70
+     * @return null|\OCP\IImage false if no preview was generated
71
+     * @since 17.0.0
72
+     */
73
+    abstract public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage;
74
+
75
+    protected function useTempFile(File $file): bool {
76
+        return $file->isEncrypted() || !$file->getStorage()->isLocal();
77
+    }
78
+
79
+    /**
80
+     * Get a path to either the local file or temporary file
81
+     *
82
+     * @param File $file
83
+     * @param int $maxSize maximum size for temporary files
84
+     * @return string|false
85
+     */
86
+    protected function getLocalFile(File $file, int $maxSize = null) {
87
+        if ($this->useTempFile($file)) {
88
+            $absPath = \OC::$server->getTempManager()->getTemporaryFile();
89
+
90
+            $content = $file->fopen('r');
91
+
92
+            if ($maxSize) {
93
+                $content = stream_get_contents($content, $maxSize);
94
+            }
95
+
96
+            file_put_contents($absPath, $content);
97
+            $this->tmpFiles[] = $absPath;
98
+            return $absPath;
99
+        } else {
100
+            $path = $file->getStorage()->getLocalFile($file->getInternalPath());
101
+            if (is_string($path)) {
102
+                return $path;
103
+            } else {
104
+                return false;
105
+            }
106
+        }
107
+    }
108
+
109
+    /**
110
+     * Clean any generated temporary files
111
+     */
112
+    protected function cleanTmpFiles(): void {
113
+        foreach ($this->tmpFiles as $tmpFile) {
114
+            unlink($tmpFile);
115
+        }
116
+
117
+        $this->tmpFiles = [];
118
+    }
119 119
 }
Please login to merge, or discard this patch.
lib/private/Preview/PDF.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 //.pdf
27 27
 class PDF extends Bitmap {
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getMimeType(): string {
32
-		return '/application\/pdf/';
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getMimeType(): string {
32
+        return '/application\/pdf/';
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Preview/Photoshop.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 //.psd
27 27
 class Photoshop extends Bitmap {
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getMimeType(): string {
32
-		return '/application\/x-photoshop/';
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getMimeType(): string {
32
+        return '/application\/x-photoshop/';
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Preview/Font.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
 
25 25
 // .otf, .ttf and .pfb
26 26
 class Font extends Bitmap {
27
-	/**
28
-	 * {@inheritDoc}
29
-	 */
30
-	public function getMimeType(): string {
31
-		return '/application\/(?:font-sfnt|x-font$)/';
32
-	}
27
+    /**
28
+     * {@inheritDoc}
29
+     */
30
+    public function getMimeType(): string {
31
+        return '/application\/(?:font-sfnt|x-font$)/';
32
+    }
33 33
 }
Please login to merge, or discard this patch.
lib/private/Preview/StarOffice.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 
24 24
 //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm
25 25
 class StarOffice extends Office {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType(): string {
30
-		return '/application\/vnd.sun.xml.*/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType(): string {
30
+        return '/application\/vnd.sun.xml.*/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/MSOffice2007.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 
24 24
 //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx
25 25
 class MSOffice2007 extends Office {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType(): string {
30
-		return '/application\/vnd.openxmlformats-officedocument.*/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType(): string {
30
+        return '/application\/vnd.openxmlformats-officedocument.*/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/TIFF.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 //.tiff
27 27
 class TIFF extends Bitmap {
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getMimeType(): string {
32
-		return '/image\/tiff/';
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getMimeType(): string {
32
+        return '/image\/tiff/';
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Preview/BMP.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
 namespace OC\Preview;
24 24
 
25 25
 class BMP extends Image {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getMimeType(): string {
30
-		return '/image\/bmp/';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getMimeType(): string {
30
+        return '/image\/bmp/';
31
+    }
32 32
 }
Please login to merge, or discard this patch.
lib/private/Preview/Illustrator.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 
26 26
 //.ai
27 27
 class Illustrator extends Bitmap {
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getMimeType(): string {
32
-		return '/application\/illustrator/';
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getMimeType(): string {
32
+        return '/application\/illustrator/';
33
+    }
34 34
 }
Please login to merge, or discard this patch.