Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
SlideMaster
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
8 / 8
9
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
 createSlideLayout
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 addSlideLayout
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAllSlideLayouts
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTextStyles
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTextStyles
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addSchemeColor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAllSchemeColors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
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 * @see        https://github.com/PHPOffice/PHPPresentation
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18declare(strict_types=1);
19
20namespace PhpOffice\PhpPresentation\Slide;
21
22use PhpOffice\PhpPresentation\ComparableInterface;
23use PhpOffice\PhpPresentation\PhpPresentation;
24use PhpOffice\PhpPresentation\ShapeContainerInterface;
25use PhpOffice\PhpPresentation\Slide\Background\Color as BackgroundColor;
26use PhpOffice\PhpPresentation\Style\Color;
27use PhpOffice\PhpPresentation\Style\ColorMap;
28use PhpOffice\PhpPresentation\Style\SchemeColor;
29use PhpOffice\PhpPresentation\Style\TextStyle;
30
31class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeContainerInterface
32{
33    /**
34     * Collection of Slide objects.
35     *
36     * @var array<SlideLayout>
37     */
38    protected $slideLayouts = [];
39
40    /**
41     * Mapping of colors to the theme.
42     *
43     * @var ColorMap
44     */
45    public $colorMap;
46
47    /**
48     * @var TextStyle
49     */
50    protected $textStyles;
51
52    /**
53     * @var array<SchemeColor>
54     */
55    protected $arraySchemeColor = [];
56
57    /**
58     * @var array<string, string>
59     */
60    protected $defaultSchemeColor = [
61        'dk1' => '000000',
62        'lt1' => 'FFFFFF',
63        'dk2' => '1F497D',
64        'lt2' => 'EEECE1',
65        'accent1' => '4F81BD',
66        'accent2' => 'C0504D',
67        'accent3' => '9BBB59',
68        'accent4' => '8064A2',
69        'accent5' => '4BACC6',
70        'accent6' => 'F79646',
71        'hlink' => '0000FF',
72        'folHlink' => '800080',
73    ];
74
75    /**
76     * Create a new slideMaster.
77     */
78    public function __construct(?PhpPresentation $pParent = null)
79    {
80        // Set parent
81        $this->parent = $pParent;
82        // Set identifier
83        $this->identifier = md5(mt_rand(0, 9999) . time());
84        // Set a basic colorMap
85        $this->colorMap = new ColorMap();
86        // Set a white background
87        $this->background = new BackgroundColor();
88        $this->background->setColor(new Color(Color::COLOR_WHITE));
89        // Set basic textStyles
90        $this->textStyles = new TextStyle(true);
91        // Set basic scheme colors
92        foreach ($this->defaultSchemeColor as $key => $value) {
93            $oSchemeColor = new SchemeColor();
94            $oSchemeColor->setValue($key);
95            $oSchemeColor->setRGB($value);
96            $this->addSchemeColor($oSchemeColor);
97        }
98    }
99
100    /**
101     * Create a slideLayout and add it to this presentation.
102     */
103    public function createSlideLayout(): SlideLayout
104    {
105        $newSlideLayout = new SlideLayout($this);
106        $this->addSlideLayout($newSlideLayout);
107
108        return $newSlideLayout;
109    }
110
111    /**
112     * Add slideLayout.
113     */
114    public function addSlideLayout(?SlideLayout $slideLayout = null): SlideLayout
115    {
116        $this->slideLayouts[] = $slideLayout;
117
118        return $slideLayout;
119    }
120
121    /**
122     * @return array<SlideLayout>
123     */
124    public function getAllSlideLayouts(): array
125    {
126        return $this->slideLayouts;
127    }
128
129    public function getTextStyles(): TextStyle
130    {
131        return $this->textStyles;
132    }
133
134    public function setTextStyles(TextStyle $textStyle): self
135    {
136        $this->textStyles = $textStyle;
137
138        return $this;
139    }
140
141    public function addSchemeColor(SchemeColor $schemeColor): self
142    {
143        $this->arraySchemeColor[$schemeColor->getValue()] = $schemeColor;
144
145        return $this;
146    }
147
148    /**
149     * @return array<SchemeColor>
150     */
151    public function getAllSchemeColors(): array
152    {
153        return $this->arraySchemeColor;
154    }
155}