Completed
Pull Request — develop (#178)
by
unknown
09:34
created

Theme   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 70%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 24
ccs 7
cts 10
cp 0.7
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A writeTheme() 0 14 4
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\Writer\PowerPoint2007;
19
20
use PhpOffice\PhpPresentation\Writer\PowerPoint2007;
21
22
/**
23
 * \PhpOffice\PhpPresentation\Writer\PowerPoint2007\Theme
24
 */
25
class Theme extends AbstractPart
26
{
27
    /**
28
     * Write theme to XML format
29
     *
30
     * @param  int $masterId
31
     * @throws \Exception
32
     * @return string XML Output
33
     */
34 60
    public function writeTheme($masterId = 1)
35
    {
36
        // Write theme from layout pack
37 60
        $parentWriter = $this->getParentWriter();
38 60
        if ($parentWriter instanceof PowerPoint2007) {
39 60
            $layoutPack     = $parentWriter->getLayoutPack();
40 60
            foreach ($layoutPack->getThemes() as $theme) {
41 60
                if ($theme['masterid'] == $masterId) {
42 60
                    return $theme['body'];
43
                }
44
            }
45
            throw new \Exception('No theme has been found!');
46
        }
47
    }
48
}
49