Completed
Pull Request — develop (#588)
by
unknown
08:47
created

PresentationProperties::getShowType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4
 * presentations documents.
5
 *
6
 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7
 * General Public License version 3 as published by the Free Software Foundation.
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code. For the full list of
11
 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12
 *
13
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
namespace PhpOffice\PhpPresentation;
18
19
/**
20
 * \PhpOffice\PhpPresentation\PresentationProperties
21
 */
22
class PresentationProperties
23
{
24
    const VIEW_HANDOUT = 'handoutView';
25
    const VIEW_NOTES = 'notesView';
26
    const VIEW_NOTES_MASTER = 'notesMasterView';
27
    const VIEW_OUTLINE = 'outlineView';
28
    const VIEW_SLIDE = 'sldView';
29
    const VIEW_SLIDE_MASTER = 'sldMasterView';
30
    const VIEW_SLIDE_SORTER = 'sldSorterView';
31
    const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
32
33
    protected $arrayView = array(
34
        self::VIEW_HANDOUT,
35
        self::VIEW_NOTES,
36
        self::VIEW_NOTES_MASTER,
37
        self::VIEW_OUTLINE,
38
        self::VIEW_SLIDE,
39
        self::VIEW_SLIDE_MASTER,
40
        self::VIEW_SLIDE_SORTER,
41
        self::VIEW_SLIDE_THUMBNAIL,
42
    );
43
44
    const SHOW_TYPE_PRESENT = 'present';
45
    const SHOW_TYPE_BROWSE = 'browse';
46
    const SHOW_TYPE_KIOSK = 'kiosk';
47
48
    protected $arrayShowTypes = array(
49
        self::SHOW_TYPE_PRESENT,
50
        self::SHOW_TYPE_BROWSE,
51
        self::SHOW_TYPE_KIOSK,
52
    );
53
54
    /*
55
     * @var boolean
56
     */
57
    protected $isLoopUntilEsc = false;
58
59
    /**
60
     * Mark as final
61
     * @var bool
62
     */
63
    protected $markAsFinal = false;
64
65
    /*
66
     * @var string
67
     */
68
    protected $thumbnail;
69
70
    /**
71
     * Zoom
72
     * @var float
73
     */
74
    protected $zoom = 1;
75
76
    /*
77
     * @var string
78
     */
79
    protected $lastView = self::VIEW_SLIDE;
80
81
    /*
82
     * @var boolean
83
     */
84
    protected $isCommentVisible = false;
85
    
86
    /*
87
     * @var string
88
     */
89
    protected $showType = self::SHOW_TYPE_PRESENT;
90
    
91
    /**
92
     * @return bool
93
     */
94 177
    public function isLoopContinuouslyUntilEsc()
95
    {
96 177
        return $this->isLoopUntilEsc;
97
    }
98
    
99
    /**
100
     * @param bool $value
101
     * @return \PhpOffice\PhpPresentation\PresentationProperties
102
     */
103 1
    public function setLoopContinuouslyUntilEsc($value = false)
104
    {
105 1
        if (is_bool($value)) {
106 1
            $this->isLoopUntilEsc = $value;
107
        }
108 1
        return $this;
109
    }
110
    
111
    /**
112
     * Return the thumbnail file path
113
     * @return string
114
     */
115 176
    public function getThumbnailPath()
116
    {
117 176
        return $this->thumbnail;
118
    }
119
    
120
    /**
121
     * Define the path for the thumbnail file / preview picture
122
     * @param string $path
123
     * @return \PhpOffice\PhpPresentation\PresentationProperties
124
     */
125 4
    public function setThumbnailPath($path = '')
126
    {
127 4
        if (file_exists($path)) {
128 4
            $this->thumbnail = $path;
129
        }
130 4
        return $this;
131
    }
132
133
    /**
134
     * Mark a document as final
135
     * @param bool $state
136
     * @return PresentationProperties
137
     */
138 7
    public function markAsFinal($state = true)
139
    {
140 7
        if (is_bool($state)) {
141 7
            $this->markAsFinal = $state;
142
        }
143 7
        return $this;
144
    }
145
146
    /**
147
     * Return if this document is marked as final
148
     * @return bool
149
     */
150 116
    public function isMarkedAsFinal()
151
    {
152 116
        return $this->markAsFinal;
153
    }
154
155
    /**
156
     * Set the zoom of the document (in percentage)
157
     * @param float $zoom
158
     * @return PresentationProperties
159
     */
160 6
    public function setZoom($zoom = 1.0)
161
    {
162 6
        if (is_numeric($zoom)) {
163 6
            $this->zoom = (float)$zoom;
164
        }
165 6
        return $this;
166
    }
167
168
    /**
169
     * Return the zoom (in percentage)
170
     * @return float
171
     */
172 115
    public function getZoom()
173
    {
174 115
        return $this->zoom;
175
    }
176
177
    /**
178
     * @param string $value
179
     * @return $this
180
     */
181 2
    public function setLastView($value = self::VIEW_SLIDE)
182
    {
183 2
        if (in_array($value, $this->arrayView)) {
184 2
            $this->lastView = $value;
185
        }
186 2
        return $this;
187
    }
188
189
    /**
190
     * @return string
191
     */
192 113
    public function getLastView()
193
    {
194 113
        return $this->lastView;
195
    }
196
197
    /**
198
     * @param bool $value
199
     * @return $this
200
     */
201 2
    public function setCommentVisible($value = false)
202
    {
203 2
        if (is_bool($value)) {
204 2
            $this->isCommentVisible = $value;
205
        }
206 2
        return $this;
207
    }
208
209
    /**
210
     * @return string
211
     */
212 113
    public function isCommentVisible()
213
    {
214 113
        return $this->isCommentVisible;
215
    }
216
217
    /**
218
     * @return string
219
     */
220 112
    public function getShowType()
221
    {
222 112
        return $this->showType;
223
    }
224
    
225
    /**
226
     * @param string $value
227
     * @return \PhpOffice\PhpPresentation\PresentationProperties
228
     */
229
    public function setShowType($value = self::SHOW_TYPE_PRESENT)
230
    {
231
        if (in_array($value, $this->arrayShowTypes)) {
232
            $this->showType = $value;
233
        }
234
        return $this;
235
    }
236
}
237