This repository was archived by the owner on Apr 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAbstract2Image.php
More file actions
63 lines (55 loc) · 1.67 KB
/
Abstract2Image.php
File metadata and controls
63 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace ConvertAPI;
require_once('ConvertAPI.php');
/**
* Extends the ConvertAPI class to convert various documents into image format
* via convertapi.com.
*/
abstract class Abstract2Image extends ConvertAPI {
/* Magic methods. */
/**
* Magic setter method. Checks and sets values for $_additionalParameters.
*
* @param string $name Name of the additional parameter to set.
* @param string $value Value to set the parameter to.
*/
public function __set($name, $value) {
switch ($name) {
case 'OutputFormat':
if (is_string($value) && in_array($value, array('png', 'jpg', 'tif'))) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be "png", "jpg" or "tif".');
}
break;
case 'JpgQuality':
if (is_int($value) && $value >= 1 && $value <= 100) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be an integer between 1 and 100.');
}
break;
case 'ImageResolutionH': case 'ImageResolutionV':
if (is_int($value) && $value >= 72 && $value <= 1200) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be an integer between 72 and 1200.');
}
break;
case 'StoreFile':
if (is_bool($value)) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be a boolean value.');
}
break;
case 'Timeout':
if (is_int($value) && $value >= 5 && $value <= 1200) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be an integer between 5 and 1200.');
}
break;
}
}
}