Completed
Pull Request — develop (#188)
by Franck
06:55
created

DocPropsThumbnail   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 4
dl 0
loc 27
ccs 13
cts 13
cp 1
rs 10

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
     */
10 75
    public function render()
11
    {
12 75
        $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
13
14 75
        if ($pathThumbnail) {
15 2
            $fileThumbnail = file_get_contents($pathThumbnail);
16 2
            $gdImage = imagecreatefromstring($fileThumbnail);
17 2
            if ($gdImage) {
18 2
                ob_start();
19 2
                imagejpeg($gdImage);
20 2
                $imageContents = ob_get_contents();
21 2
                ob_end_clean();
22 2
                imagedestroy($gdImage);
23
24 2
                $this->getZip()->addFromString('docProps/thumbnail.jpeg', $imageContents);
25
            }
26
        }
27
28
        // Return
29 75
        return $this->getZip();
30
    }
31
}
32