PageCompressionTrait::getArgumentValue()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
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\Device\DistillerParameters;
9
10
/**
11
 * The page compression distiller parameters trait.
12
 *
13
 * @package GravityMedia\Ghostscript\Device\DistillerParameters
14
 *
15
 * @link    http://ghostscript.com/doc/current/Ps2pdf.htm
16
 */
17
trait PageCompressionTrait
18
{
19
    /**
20
     * Get argument value
21
     *
22
     * @param string $name
23
     *
24
     * @return null|string
25
     */
26
    abstract protected function getArgumentValue($name);
27
28
    /**
29
     * Set argument
30
     *
31
     * @param string $argument
32
     *
33
     * @return $this
34
     */
35
    abstract protected function setArgument($argument);
36
37
    /**
38
     * Whether to compress pages
39
     *
40
     * @return bool
41
     */
42 2
    public function isCompressPages()
43
    {
44 2
        $value = $this->getArgumentValue('-dCompressPages');
45 2
        if (null === $value) {
46 2
            return true;
47
        }
48
49 2
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
50
    }
51
52
    /**
53
     * Set compress pages flag
54
     *
55
     * @param true $compressPages
56
     *
57
     * @return $this
58
     */
59 2
    public function setCompressPages($compressPages)
60
    {
61 2
        $this->setArgument(sprintf('-dCompressPages=%s', $compressPages ? 'true' : 'false'));
62
63 2
        return $this;
64
    }
65
66
    /**
67
     * Whether to LZW encode pages
68
     *
69
     * @return bool
70
     */
71 2
    public function isLzwEncodePages()
72
    {
73 2
        $value = $this->getArgumentValue('-dLZWEncodePages');
74 2
        if (null === $value) {
75 2
            return false;
76
        }
77
78 2
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
79
    }
80
81
    /**
82
     * Set LZW encode pages flag
83
     *
84
     * @param string $lzwEncodePages
85
     *
86
     * @return $this
87
     */
88 2
    public function setLzwEncodePages($lzwEncodePages)
89
    {
90 2
        $this->setArgument(sprintf('-dLZWEncodePages=%s', $lzwEncodePages ? 'true' : 'false'));
91
92 2
        return $this;
93
    }
94
}
95