Completed
Pull Request — develop (#565)
by
unknown
06:14
created

DocPropsThumbnail   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 30.76%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 28
ccs 4
cts 13
cp 0.3076
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 21 3
1
<?php
2
3
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
4
5
class DocPropsThumbnail extends AbstractDecoratorWriter
6
{
7
    /**
8
     * @return \PhpOffice\Common\Adapter\Zip\ZipInterface
9
     * @throws \Exception
10
     */
11 5
    public function render()
12
    {
13 5
        $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
14
15 5
        if ($pathThumbnail) {
16
            $fileThumbnail = file_get_contents($pathThumbnail);
17
            $gdImage = imagecreatefromstring($fileThumbnail);
18
            if ($gdImage) {
19
                ob_start();
20
                imagejpeg($gdImage);
21
                $imageContents = ob_get_contents();
22
                ob_end_clean();
23
                imagedestroy($gdImage);
24
25
                $this->getZip()->addFromString('docProps/thumbnail.jpeg', $imageContents);
26
            }
27
        }
28
29
        // Return
30 5
        return $this->getZip();
31
    }
32
}
33