Completed
Pull Request — develop (#230)
by Franck
08:28
created

Slide::getExtentX()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

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