Completed
Pull Request — develop (#565)
by
unknown
07:15
created

Pictures   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 7
dl 0
loc 30
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 22 5
1
<?php
2
3
namespace PhpOffice\PhpPresentation\Writer\ODPresentation;
4
5
use PhpOffice\Common\Adapter\Zip\ZipInterface;
6
use PhpOffice\PhpPresentation\Shape\Drawing;
7
use PhpOffice\PhpPresentation\Slide\Background\Image;
8
9
class Pictures extends AbstractDecoratorWriter
10
{
11
    /**
12
     * @return ZipInterface
13
     * @throws \Exception
14
     */
15
16 62
    public function render()
17
    {
18 62
        $arrMedia = array();
19 62
        for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
20 32
            $shape = $this->getDrawingHashTable()->getByIndex($i);
21 32
            if (!($shape instanceof Drawing\AbstractDrawingAdapter)) {
22 24
                continue;
23
            }
24 9
            $arrMedia[] = $shape->getIndexedFilename();
25 9
            $this->getZip()->addFromString('Pictures/' . $shape->getIndexedFilename(), $shape->getContents());
26
        }
27
28 62
        foreach ($this->getPresentation()->getAllSlides() as $keySlide => $oSlide) {
29
            // Add background image slide
30 62
            $oBkgImage = $oSlide->getBackground();
31 62
            if ($oBkgImage instanceof Image) {
32 62
                $this->getZip()->addFromString('Pictures/'.$oBkgImage->getIndexedFilename($keySlide), file_get_contents($oBkgImage->getPath()));
33
            }
34
        }
35
        
36 62
        return $this->getZip();
37
    }
38
}
39