Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
97.30% covered (success)
97.30%
36 / 37
93.75% covered (success)
93.75%
15 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 1
PresentationProperties
97.30% covered (success)
97.30%
36 / 37
93.75% covered (success)
93.75%
15 / 16
25
0.00% covered (danger)
0.00%
0 / 1
 isLoopContinuouslyUntilEsc
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLoopContinuouslyUntilEsc
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getThumbnailPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getThumbnail
85.71% covered (warning)
85.71%
6 / 7
0.00% covered (danger)
0.00%
0 / 1
4.05
 setThumbnailPath
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
5
 getThumbnailType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 markAsFinal
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isMarkedAsFinal
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setZoom
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getZoom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLastView
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getLastView
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCommentVisible
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isCommentVisible
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSlideshowType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSlideshowType
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
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 * @see        https://github.com/PHPOffice/PHPPresentation
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18declare(strict_types=1);
19
20namespace PhpOffice\PhpPresentation;
21
22class PresentationProperties
23{
24    public const VIEW_HANDOUT = 'handoutView';
25    public const VIEW_NOTES = 'notesView';
26    public const VIEW_NOTES_MASTER = 'notesMasterView';
27    public const VIEW_OUTLINE = 'outlineView';
28    public const VIEW_SLIDE = 'sldView';
29    public const VIEW_SLIDE_MASTER = 'sldMasterView';
30    public const VIEW_SLIDE_SORTER = 'sldSorterView';
31    public const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
32
33    public const THUMBNAIL_FILE = 'file';
34    public const THUMBNAIL_DATA = 'data';
35
36    /**
37     * @var array<int, string>
38     */
39    protected $arrayView = [
40        self::VIEW_HANDOUT,
41        self::VIEW_NOTES,
42        self::VIEW_NOTES_MASTER,
43        self::VIEW_OUTLINE,
44        self::VIEW_SLIDE,
45        self::VIEW_SLIDE_MASTER,
46        self::VIEW_SLIDE_SORTER,
47        self::VIEW_SLIDE_THUMBNAIL,
48    ];
49
50    public const SLIDESHOW_TYPE_PRESENT = 'present';
51    public const SLIDESHOW_TYPE_BROWSE = 'browse';
52    public const SLIDESHOW_TYPE_KIOSK = 'kiosk';
53
54    /**
55     * @var array<int, string>
56     */
57    protected $arraySlideshowTypes = [
58        self::SLIDESHOW_TYPE_PRESENT,
59        self::SLIDESHOW_TYPE_BROWSE,
60        self::SLIDESHOW_TYPE_KIOSK,
61    ];
62
63    /**
64     * @var bool
65     */
66    protected $isLoopUntilEsc = false;
67
68    /**
69     * Mark as final.
70     *
71     * @var bool
72     */
73    protected $markAsFinal = false;
74
75    /**
76     * @var null|string Define the thumbnail content (if content into zip file)
77     */
78    protected $thumbnail;
79
80    /**
81     * @var null|string Define the thumbnail place
82     */
83    protected $thumbnailPath;
84
85    /**
86     * @var string Define if thumbnail is out of PPT or previouly store into PPT
87     */
88    protected $thumbnailType = self::THUMBNAIL_FILE;
89
90    /**
91     * Zoom.
92     *
93     * @var float
94     */
95    protected $zoom = 1.0;
96
97    /**
98     * @var string
99     */
100    protected $lastView = self::VIEW_SLIDE;
101
102    /**
103     * @var string
104     */
105    protected $slideshowType = self::SLIDESHOW_TYPE_PRESENT;
106
107    /**
108     * @var bool
109     */
110    protected $isCommentVisible = false;
111
112    public function isLoopContinuouslyUntilEsc(): bool
113    {
114        return $this->isLoopUntilEsc;
115    }
116
117    public function setLoopContinuouslyUntilEsc(bool $value = false): self
118    {
119        $this->isLoopUntilEsc = $value;
120
121        return $this;
122    }
123
124    /**
125     * Return the thumbnail file path.
126     */
127    public function getThumbnailPath(): ?string
128    {
129        return $this->thumbnailPath;
130    }
131
132    /**
133     * Return the content of thumbnail.
134     */
135    public function getThumbnail(): ?string
136    {
137        // Return content of local file
138        if ($this->getThumbnailType() == self::THUMBNAIL_FILE) {
139            if ($this->getThumbnailPath()) {
140                return file_get_contents($this->getThumbnailPath());
141            }
142
143            return null;
144        }
145
146        // Return content of image stored into zip file
147        if ($this->getThumbnailType() == self::THUMBNAIL_DATA) {
148            return $this->thumbnail;
149        }
150
151        return null;
152    }
153
154    /**
155     * Define the path for the thumbnail file / preview picture.
156     */
157    public function setThumbnailPath(string $path = '', string $type = self::THUMBNAIL_FILE, ?string $content = null): self
158    {
159        if (file_exists($path) && $type == self::THUMBNAIL_FILE) {
160            $this->thumbnailPath = $path;
161            $this->thumbnailType = $type;
162        }
163        if ($content != '' && $type == self::THUMBNAIL_DATA) {
164            $this->thumbnailPath = '';
165            $this->thumbnailType = $type;
166            $this->thumbnail = $content;
167        }
168
169        return $this;
170    }
171
172    /**
173     * Return the thumbnail type.
174     */
175    public function getThumbnailType(): string
176    {
177        return $this->thumbnailType;
178    }
179
180    /**
181     * Mark a document as final.
182     */
183    public function markAsFinal(bool $state = true): self
184    {
185        $this->markAsFinal = $state;
186
187        return $this;
188    }
189
190    /**
191     * Return if this document is marked as final.
192     */
193    public function isMarkedAsFinal(): bool
194    {
195        return $this->markAsFinal;
196    }
197
198    /**
199     * Set the zoom of the document (in percentage).
200     */
201    public function setZoom(float $zoom = 1.0): self
202    {
203        $this->zoom = $zoom;
204
205        return $this;
206    }
207
208    /**
209     * Return the zoom (in percentage).
210     */
211    public function getZoom(): float
212    {
213        return $this->zoom;
214    }
215
216    public function setLastView(string $value = self::VIEW_SLIDE): self
217    {
218        if (in_array($value, $this->arrayView)) {
219            $this->lastView = $value;
220        }
221
222        return $this;
223    }
224
225    public function getLastView(): string
226    {
227        return $this->lastView;
228    }
229
230    public function setCommentVisible(bool $value = false): self
231    {
232        $this->isCommentVisible = $value;
233
234        return $this;
235    }
236
237    public function isCommentVisible(): bool
238    {
239        return $this->isCommentVisible;
240    }
241
242    public function getSlideshowType(): string
243    {
244        return $this->slideshowType;
245    }
246
247    public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self
248    {
249        if (in_array($value, $this->arraySlideshowTypes)) {
250            $this->slideshowType = $value;
251        }
252
253        return $this;
254    }
255}