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

SlideMaster::getAllSlideLayouts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\SchemeColor;
26
use PhpOffice\PhpPresentation\Style\TextStyle;
27
28
/**
29
 * Class SlideMaster
30
 */
31
class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
32
{
33
    /**
34
     * Collection of Slide objects
35
     *
36
     * @var \PhpOffice\PhpPresentation\Slide\SlideLayout[]
37
     */
38
    protected $slideLayouts = array();
39
    /**
40
     * Mapping of colors to the theme
41
     *
42
     * @var \PhpOffice\PhpPresentation\Style\ColorMap
43
     */
44
    public $colorMap;
45
    /**
46
     * @var \PhpOffice\PhpPresentation\Style\TextStyle
47
     */
48
    protected $textStyles;
49
    /**
50
     * @var \PhpOffice\PhpPresentation\Style\SchemeColor[]
51
     */
52
    protected $arraySchemeColor = array();
53
54
    /**
55
     * Create a new slideMaster
56
     *
57
     * @param PhpPresentation $pParent
58
     */
59
    public function __construct(PhpPresentation $pParent = null)
60
    {
61
        // Set parent
62
        $this->parent = $pParent;
63
        // Shape collection
64
        $this->shapeCollection = new \ArrayObject();
65
        // Set identifier
66
        $this->identifier = md5(rand(0, 9999) . time());
67
        // Set a basic colorMap
68
        $this->colorMap = new ColorMap();
69
        // Set a white background
70
        $this->background = new BackgroundColor();
71
        $this->background->setColor(new Color(Color::COLOR_WHITE));
72
        // Set basic textStyles
73
        $this->textStyles = new TextStyle(true);
74
    }
75
76
    /**
77
     * Create a slideLayout and add it to this presentation
78
     *
79
     * @return \PhpOffice\PhpPresentation\Slide\SlideLayout
80
     */
81
    public function createSlideLayout()
82
    {
83
        $newSlideLayout = new SlideLayout($this);
84
        $this->addSlideLayout($newSlideLayout);
85
        return $newSlideLayout;
86
    }
87
88
    /**
89
     * Add slideLayout
90
     *
91
     * @param  \PhpOffice\PhpPresentation\Slide\SlideLayout $slideLayout
92
     * @throws \Exception
93
     * @return \PhpOffice\PhpPresentation\Slide\SlideLayout
94
     */
95
    public function addSlideLayout(SlideLayout $slideLayout = null)
96
    {
97
        $this->slideLayouts[] = $slideLayout;
98
        return $slideLayout;
99
    }
100
101
    /**
102
     * @return SlideLayout[]
103
     */
104
    public function getAllSlideLayouts()
105
    {
106
        return $this->slideLayouts;
107
    }
108
109
    /**
110
     * @return TextStyle
111
     */
112
    public function getTextStyles()
113
    {
114
        return $this->textStyles;
115
    }
116
117
    /**
118
     * @param TextStyle $textStyle
119
     * @return $this
120
     */
121
    public function setTextStyles(TextStyle $textStyle)
122
    {
123
        $this->textStyles = $textStyle;
124
        return $this;
125
    }
126
127
    /**
128
     * @param SchemeColor $schemeColor
129
     * @return $this
130
     */
131
    public function addSchemeColor(SchemeColor $schemeColor)
132
    {
133
        $this->arraySchemeColor[] = $schemeColor;
134
        return $this;
135
    }
136
137
    /**
138
     * @return \PhpOffice\PhpPresentation\Style\SchemeColor[]
139
     */
140
    public function getAllSchemeColors()
141
    {
142
        return $this->arraySchemeColor;
143
    }
144
}
145