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

SlideMaster::getTextStyles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
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\Slide;
18
19
use PhpOffice\PhpPresentation\ComparableInterface;
20
use PhpOffice\PhpPresentation\PhpPresentation;
21
use PhpOffice\PhpPresentation\ShapeContainerInterface;
22
use PhpOffice\PhpPresentation\Slide\Background\Color as BackgroundColor;
23
use PhpOffice\PhpPresentation\Style\Color;
24
use PhpOffice\PhpPresentation\Style\ColorMap;
25
use PhpOffice\PhpPresentation\Style\TextStyle;
26
27
/**
28
 * Class SlideMaster
29
 */
30
class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
31
{
32
    /**
33
     * Collection of Slide objects
34
     *
35
     * @var \PhpOffice\PhpPresentation\Slide\SlideLayout[]
36
     */
37
    protected $slideLayouts = array();
38
    /**
39
     * Mapping of colors to the theme
40
     *
41
     * @var \PhpOffice\PhpPresentation\Style\ColorMap
42
     */
43
    public $colorMap;
44
    /**
45
     * @var \PhpOffice\PhpPresentation\Style\TextStyle
46
     */
47
    protected $textStyles;
48
49
    /**
50
     * @return TextStyle
51
     */
52 95
    public function getTextStyles()
53
    {
54 95
        return $this->textStyles;
55
    }
56
57
    /**
58
     * Create a new slideMaster
59
     *
60
     * @param PhpPresentation $pParent
61
     */
62 191
    public function __construct(PhpPresentation $pParent = null)
63
    {
64
        // Set parent
65 191
        $this->parent = $pParent;
66
        // Shape collection
67 191
        $this->shapeCollection = new \ArrayObject();
68
        // Set identifier
69 191
        $this->identifier = md5(rand(0, 9999) . time());
70
        // Set a basic colorMap
71 191
        $this->colorMap = new ColorMap();
72 191
        $this->background = new BackgroundColor();
73 191
        $this->background->setColor(new Color(Color::COLOR_WHITE));
74
        // Set basic textStyles
75 191
        $this->textStyles = new TextStyle(true);
76 191
    }
77
78
    /**
79
     * Create a slideLayout and add it to this presentation
80
     *
81
     * @return \PhpOffice\PhpPresentation\Slide\SlideLayout
82
     */
83 191
    public function createSlideLayout()
84
    {
85 191
        $newSlideLayout = new SlideLayout($this);
86 191
        $this->addSlideLayout($newSlideLayout);
87 191
        return $newSlideLayout;
88
    }
89
90
    /**
91
     * Add slideLayout
92
     *
93
     * @param  \PhpOffice\PhpPresentation\Slide\SlideLayout $slide
94
     * @throws \Exception
95
     * @return \PhpOffice\PhpPresentation\Slide\SlideLayout
96
     */
97 191
    public function addSlideLayout(SlideLayout $slide = null)
98
    {
99 191
        $this->slideLayouts[] = $slide;
100 191
        return $slide;
101
    }
102
103 95
    public function getAllSlideLayouts()
104
    {
105 95
        return $this->slideLayouts;
106
    }
107
}
108