|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Ghostscript package |
|
4
|
|
|
* |
|
5
|
|
|
* @author Daniel Schr�der <[email protected]> |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace GravityMedia\Ghostscript\Devices; |
|
9
|
|
|
|
|
10
|
|
|
use GravityMedia\Ghostscript\Process\Arguments as ProcessArguments; |
|
11
|
|
|
use Symfony\Component\Process\Process; |
|
12
|
|
|
use Symfony\Component\Process\ProcessBuilder; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* The abstract device class |
|
16
|
|
|
* |
|
17
|
|
|
* @package GravityMedia\Ghostscript\Devices |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractDevice |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* The process builder object |
|
23
|
|
|
* |
|
24
|
|
|
* @var Process |
|
25
|
|
|
*/ |
|
26
|
|
|
private $builder; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The arguments object |
|
30
|
|
|
* |
|
31
|
|
|
* @var ProcessArguments |
|
32
|
|
|
*/ |
|
33
|
|
|
private $arguments; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Create abstract device object |
|
37
|
|
|
* |
|
38
|
|
|
* @param ProcessBuilder $builder |
|
39
|
|
|
* @param ProcessArguments $arguments |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(ProcessBuilder $builder, ProcessArguments $arguments) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->builder = $builder; |
|
|
|
|
|
|
44
|
|
|
$this->arguments = $arguments; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get argument value |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $name |
|
51
|
|
|
* |
|
52
|
|
|
* @return null|string |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function getArgumentValue($name) |
|
55
|
|
|
{ |
|
56
|
|
|
$argument = $this->arguments->getArgument($name); |
|
57
|
|
|
if (null === $argument) { |
|
58
|
|
|
return null; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $argument->getValue(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Set argument |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $argument |
|
68
|
|
|
* |
|
69
|
|
|
* @return $this |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function setArgument($argument) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->arguments->setArgument($argument); |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Create process object |
|
80
|
|
|
* |
|
81
|
|
|
* @param string $inputFile |
|
82
|
|
|
* |
|
83
|
|
|
* @throws \RuntimeException |
|
84
|
|
|
* |
|
85
|
|
|
* @return Process |
|
86
|
|
|
*/ |
|
87
|
|
|
public function createProcess($inputFile) |
|
88
|
|
|
{ |
|
89
|
|
|
if (!is_file($inputFile)) { |
|
90
|
|
|
throw new \RuntimeException('Input file does not exist'); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$arguments = array_values($this->arguments->toArray()); |
|
94
|
|
|
array_push($arguments, '-f', $inputFile); |
|
95
|
|
|
|
|
96
|
|
|
return $this->builder->setArguments($arguments)->getProcess(); |
|
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..