Options::getTermEncoding()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @author: Viskov Sergey
4
 * @date  : 4/28/16
5
 * @time  : 6:54 PM
6
 */
7
8
namespace LTDBeget\vim;
9
10
/**
11
 * Class Options
12
 *
13
 * @package LTDBeget\vim
14
 */
15
final class Options
16
{
17
    /**
18
     * @var bool
19
     */
20
    private $diffMode = false;
21
22
    /**
23
     * @var bool
24
     */
25
    private $easyMode = false;
26
27
    /**
28
     * @var bool
29
     */
30
    private $readonlyMode = false;
31
32
    /**
33
     * @var string
34
     */
35
    private $encoding;
36
37
38
    /**
39
     * @var string
40
     */
41
    private $termEncoding;
42
43
44
    /**
45
     * @return string
46
     */
47
    public function getTermEncoding()
48
    {
49
        return $this->termEncoding;
50
    }
51
52
53
    /**
54
     * @param string $termEncoding
55
     *
56
     * @return Options
57
     */
58
    public function setTermEncoding(string $termEncoding)
59
    {
60
        $this->termEncoding = $termEncoding;
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getEncoding()
69
    {
70
        return $this->encoding;
71
    }
72
73
74
    /**
75
     * set encoding=<your encoding>
76
     * @param string $encoding
77
     *
78
     * @return Options
79
     */
80
    public function setEncoding(string $encoding) : Options
81
    {
82
        $this->encoding = $encoding;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @return bool
89
     */
90
    public function isDiffMode()
91
    {
92
        return $this->diffMode;
93
    }
94
95
    /**
96
     * @param bool $diffMode
97
     * @return Options
98
     */
99
    public function setDiffMode(bool $diffMode) : Options
100
    {
101
        $this->diffMode = $diffMode;
102
103
        return $this;
104
    }
105
106
    /**
107
     * @return bool
108
     */
109
    public function isEasyMode()
110
    {
111
        return $this->easyMode;
112
    }
113
114
    /**
115
     * @param bool $easyMode
116
     * @return Options
117
     */
118
    public function setEasyMode(bool $easyMode) : Options
119
    {
120
        $this->easyMode = $easyMode;
121
122
        return $this;
123
    }
124
125
    /**
126
     * @return bool
127
     */
128
    public function isReadonlyMode()
129
    {
130
        return $this->readonlyMode;
131
    }
132
133
    /**
134
     * @param bool $readonlyMode
135
     * @return Options
136
     */
137
    public function setReadonlyMode(bool $readonlyMode) : Options
138
    {
139
        $this->readonlyMode = $readonlyMode;
140
141
        return $this;
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    public function __toString() : string
148
    {
149
        $options = [];
150
151
        if($this->isDiffMode()) {
152
            $options[] = '-d';
153
        }
154
155
        if($this->isEasyMode()) {
156
            $options[] = '-y';
157
        }
158
159
        if($this->isReadonlyMode()) {
160
            $options[] = '-R';
161
        }
162
163
        if($this->encoding) {
164
            $options[] = "-c 'set encoding=".escapeshellarg($this->encoding)."'";
165
        }
166
167
        if($this->termEncoding) {
168
            $options[] = "-c 'set termencoding=".escapeshellarg($this->termEncoding)."'";
169
        }
170
171
        return implode(' ', $options);
172
    }
173
}