Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
15 / 15
CRAP
100.00% covered (success)
100.00%
34 / 34
Slide
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
15 / 15
17
100.00% covered (success)
100.00%
34 / 34
 __construct
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
11 / 11
 getSlideLayout
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setSlideLayout
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getSlideMasterId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setSlideMasterId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 copy
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getNote
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setNote
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setName
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 isVisible
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setIsVisible
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 addAnimation
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getAnimations
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setAnimations
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 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 * @copyright   2009-2015 PHPPresentation contributors
16 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17 */
18
19declare(strict_types=1);
20
21namespace PhpOffice\PhpPresentation;
22
23use PhpOffice\PhpPresentation\Slide\AbstractSlide;
24use PhpOffice\PhpPresentation\Slide\Note;
25use PhpOffice\PhpPresentation\Slide\SlideLayout;
26
27/**
28 * Slide class.
29 */
30class Slide extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
31{
32    /**
33     * The slide is shown in presentation.
34     *
35     * @var bool
36     */
37    protected $isVisible = true;
38
39    /**
40     * Slide layout.
41     *
42     * @var SlideLayout|null
43     */
44    private $slideLayout;
45
46    /**
47     * Slide master id.
48     *
49     * @var int
50     */
51    private $slideMasterId = 1;
52
53    /**
54     * @var Note
55     */
56    private $slideNote;
57
58    /**
59     * @var \PhpOffice\PhpPresentation\Slide\Animation[]
60     */
61    protected $animations = [];
62
63    /**
64     * Name of the title.
65     *
66     * @var string|null
67     */
68    protected $name;
69
70    /**
71     * Create a new slide.
72     *
73     * @param PhpPresentation $pParent
74     */
75    public function __construct(PhpPresentation $pParent = null)
76    {
77        // Set parent
78        $this->parent = $pParent;
79        // Shape collection
80        $this->shapeCollection = new \ArrayObject();
81        // Set identifier
82        $this->identifier = md5(rand(0, 9999) . time());
83        // Set Slide Layout
84        if ($this->parent instanceof PhpPresentation) {
85            $arrayMasterSlides = $this->parent->getAllMasterSlides();
86            $oMasterSlide = reset($arrayMasterSlides);
87            $arraySlideLayouts = $oMasterSlide->getAllSlideLayouts();
88            $oSlideLayout = reset($arraySlideLayouts);
89            $this->setSlideLayout($oSlideLayout);
90        }
91        // Set note
92        $this->setNote(new Note());
93    }
94
95    /**
96     * Get slide layout.
97     */
98    public function getSlideLayout(): ?SlideLayout
99    {
100        return $this->slideLayout;
101    }
102
103    /**
104     * Set slide layout.
105     */
106    public function setSlideLayout(SlideLayout $layout): self
107    {
108        $this->slideLayout = $layout;
109
110        return $this;
111    }
112
113    /**
114     * Get slide master id.
115     *
116     * @return int
117     */
118    public function getSlideMasterId()
119    {
120        return $this->slideMasterId;
121    }
122
123    /**
124     * Set slide master id.
125     *
126     * @param int $masterId
127     *
128     * @return \PhpOffice\PhpPresentation\Slide
129     */
130    public function setSlideMasterId($masterId = 1)
131    {
132        $this->slideMasterId = $masterId;
133
134        return $this;
135    }
136
137    /**
138     * Copy slide (!= clone!).
139     *
140     * @return \PhpOffice\PhpPresentation\Slide
141     */
142    public function copy()
143    {
144        $copied = clone $this;
145
146        return $copied;
147    }
148
149    public function getNote(): Note
150    {
151        return $this->slideNote;
152    }
153
154    public function setNote(Note $note = null): self
155    {
156        $this->slideNote = (is_null($note) ? new Note() : $note);
157        $this->slideNote->setParent($this);
158
159        return $this;
160    }
161
162    /**
163     * Get the name of the slide.
164     *
165     * @return string
166     */
167    public function getName(): ?string
168    {
169        return $this->name;
170    }
171
172    /**
173     * Set the name of the slide.
174     */
175    public function setName(?string $name = null): self
176    {
177        $this->name = $name;
178
179        return $this;
180    }
181
182    /**
183     * @return bool
184     */
185    public function isVisible()
186    {
187        return $this->isVisible;
188    }
189
190    /**
191     * @param bool $value
192     *
193     * @return Slide
194     */
195    public function setIsVisible($value = true)
196    {
197        $this->isVisible = (bool) $value;
198
199        return $this;
200    }
201
202    /**
203     * Add an animation to the slide.
204     *
205     * @param \PhpOffice\PhpPresentation\Slide\Animation $animation
206     *
207     * @return Slide
208     */
209    public function addAnimation($animation)
210    {
211        $this->animations[] = $animation;
212
213        return $this;
214    }
215
216    /**
217     * Get collection of animations.
218     *
219     * @return \PhpOffice\PhpPresentation\Slide\Animation[]
220     */
221    public function getAnimations()
222    {
223        return $this->animations;
224    }
225
226    /**
227     * Set collection of animations.
228     *
229     * @param \PhpOffice\PhpPresentation\Slide\Animation[] $array
230     *
231     * @return Slide
232     */
233    public function setAnimations(array $array = [])
234    {
235        $this->animations = $array;
236
237        return $this;
238    }
239}