@@ -16,9 +16,7 @@ final class Convertor
16
16
public const SUPPORTED_FORMATS = [self ::FORMAT_JPG , self ::FORMAT_PNG , self ::FORMAT_GIF ];
17
17
18
18
19
- /**
20
- * @throws \Error
21
- */
19
+ /** @throws \Error */
22
20
public function __construct ()
23
21
{
24
22
throw new \Error ('Class ' . get_class ($ this ) . ' is static and cannot be instantiated. ' );
@@ -28,25 +26,18 @@ public function __construct()
28
26
/**
29
27
* Convert first page of PDF to image and save to disk.
30
28
*
31
- * @param string $pdfPath
32
- * @param string $savePath
33
- * @param string $format
34
- * @param bool $trim
35
29
* @throws ConvertorException
36
30
*/
37
31
public static function convert (string $ pdfPath , string $ savePath , string $ format = 'jpg ' , bool $ trim = false ): void
38
32
{
39
33
if (\in_array ($ format = strtolower ($ format ), self ::SUPPORTED_FORMATS , true ) === false ) {
40
34
ConvertorException::unsupportedFormat ($ format );
41
35
}
42
-
43
36
if (\is_file ($ pdfPath ) === false ) {
44
37
ConvertorException::fileDoesNotExist ($ pdfPath );
45
38
}
46
-
47
39
try {
48
40
$ im = self ::process ($ pdfPath , $ savePath );
49
-
50
41
if ($ trim === true ) {
51
42
$ im ->setImageBorderColor ('rgb(255,255,255) ' );
52
43
$ im ->trimImage (1 );
@@ -59,8 +50,6 @@ public static function convert(string $pdfPath, string $savePath, string $format
59
50
60
51
61
52
/**
62
- * @param string $pdfPath
63
- * @param string $savePath
64
53
* @return \Imagick
65
54
* @throws ConvertorException|\ImagickException
66
55
*/
@@ -79,12 +68,8 @@ private static function process(string $pdfPath, string $savePath): \Imagick
79
68
80
69
81
70
/**
82
- * Writes a string to a file.
83
- * Moved from nette/utils
71
+ * Writes a string to a file. Moved from nette/utils
84
72
*
85
- * @param string $file
86
- * @param string $content
87
- * @param int|null $mode
88
73
* @throws ConvertorException
89
74
*/
90
75
private static function write (string $ file , string $ content , ?int $ mode = 0666 ): void
@@ -100,11 +85,8 @@ private static function write(string $file, string $content, ?int $mode = 0666):
100
85
101
86
102
87
/**
103
- * Creates a directory.
104
- * Moved from nette/utils
88
+ * Creates a directory. Moved from nette/utils
105
89
*
106
- * @param string $dir
107
- * @param int $mode
108
90
* @throws ConvertorException
109
91
*/
110
92
private static function createDir (string $ dir , int $ mode = 0777 ): void
@@ -115,13 +97,8 @@ private static function createDir(string $dir, int $mode = 0777): void
115
97
}
116
98
117
99
118
- /**
119
- * Moved from nette/utils
120
- *
121
- * @return string
122
- */
123
100
private static function getLastError (): string
124
101
{
125
102
return (string ) preg_replace ('#^\w+\(.*?\): # ' , '' , error_get_last ()['message ' ]);
126
103
}
127
- }
104
+ }
0 commit comments