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 pathAbstract2PDF.php
More file actions
57 lines (49 loc) · 1.49 KB
/
Abstract2PDF.php
File metadata and controls
57 lines (49 loc) · 1.49 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
<?php
namespace ConvertAPI;
require_once('ConvertAPI.php');
/**
* Extends the ConvertAPI class to convert various documents into PDF
* format via convertapi.com.
*/
abstract class Abstract2Pdf 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 'DocumentTitle': case 'DocumentSubject':
case 'DocumentAuthor': case 'DocumentKeywords':
if (is_string($value)) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be a string.');
}
break;
case 'OutputFormat':
if (is_string($value) && in_array($value, array('pdf', 'pdfa', 'png', 'jpg', 'tif'))) {
$this->_additionalParameters[$name] = $value;
} else {
throw new \Exception($name.' must be "pdf", "pdfa", "png", "jpg" or "tif".');
}
break;
case 'AlternativeParser': 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;
}
}
}