Completed
Push — master ( 7db5b7...e686f3 )
by Daniel
03:06
created

PageCompressionTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 78
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
getArgumentValue() 0 1 ?
setArgument() 0 1 ?
A isCompressPages() 0 9 2
A setCompressPages() 0 6 2
A isLzwEncodePages() 0 9 2
A setLzwEncodePages() 0 6 2
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
trait PageCompressionTrait
16
{
17
    /**
18
     * Get argument value
19
     *
20
     * @param string $name
21
     *
22
     * @return null|string
23
     */
24
    abstract protected function getArgumentValue($name);
25
26
    /**
27
     * Set argument
28
     *
29
     * @param string $argument
30
     *
31
     * @return $this
32
     */
33
    abstract protected function setArgument($argument);
34
35
    /**
36
     * Whether to compress pages
37
     *
38
     * @return bool
39
     */
40 3
    public function isCompressPages()
41
    {
42 3
        $value = $this->getArgumentValue('-dCompressPages');
43 3
        if (null === $value) {
44 3
            return true;
45
        }
46
47 3
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
48
    }
49
50
    /**
51
     * Set compress pages flag
52
     *
53
     * @param true $compressPages
54
     *
55
     * @return $this
56
     */
57 3
    public function setCompressPages($compressPages)
58
    {
59 3
        $this->setArgument(sprintf('-dCompressPages=%s', $compressPages ? 'true' : 'false'));
60
61 3
        return $this;
62
    }
63
64
    /**
65
     * Whether to LZW encode pages
66
     *
67
     * @return bool
68
     */
69 3
    public function isLzwEncodePages()
70
    {
71 3
        $value = $this->getArgumentValue('-dLZWEncodePages');
72 3
        if (null === $value) {
73 3
            return false;
74
        }
75
76 3
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
77
    }
78
79
    /**
80
     * Set LZW encode pages flag
81
     *
82
     * @param string $lzwEncodePages
83
     *
84
     * @return $this
85
     */
86 3
    public function setLzwEncodePages($lzwEncodePages)
87
    {
88 3
        $this->setArgument(sprintf('-dLZWEncodePages=%s', $lzwEncodePages ? 'true' : 'false'));
89
90 3
        return $this;
91
    }
92
}
93