Completed
Pull Request — develop (#230)
by Franck
07:45
created

Slide::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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