Skip to content

Commit 7eff2b7

Browse files
committed
FIXED : #24 : PHPMD Fixes
1 parent f6240dd commit 7eff2b7

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

src/PhpPowerpoint/IOFactory.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ private static function isConcreteClass($class)
4242

4343
private static function loadClass($class, $name, $type, PHPPowerPoint $phpPowerPoint = null)
4444
{
45-
if (class_exists($class) && self::isConcreteClass($class)) {
46-
if(is_null($phpPowerPoint)){
47-
return new $class();
48-
} else {
49-
return new $class($phpPowerPoint);
50-
}
51-
} else {
52-
throw new \Exception('"'.$name.'" is not a valid '.$type.'.');
53-
}
45+
if (class_exists($class) && self::isConcreteClass($class)) {
46+
if (is_null($phpPowerPoint)) {
47+
return new $class();
48+
} else {
49+
return new $class($phpPowerPoint);
50+
}
51+
} else {
52+
throw new \Exception('"'.$name.'" is not a valid '.$type.'.');
53+
}
5454
}
5555

5656
/**

src/PhpPowerpoint/Reader/Serialized.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,26 @@ public function fileSupportsUnserializePHPPowerPoint($pFilename = '')
8989
*/
9090
private function loadSerialized($pFilename)
9191
{
92-
$oArchive = new \ZipArchive();
93-
if ($oArchive->open($pFilename) === TRUE) {
94-
$xmlContent = $oArchive->getFromName('PHPPowerPoint.xml');
95-
96-
if(!empty($xmlContent)){
97-
$xmlData = simplexml_load_string($xmlContent);
98-
$file = unserialize(base64_decode((string) $xmlData->data));
99-
100-
// Update media links
101-
for ($i = 0; $i < $file->getSlideCount(); ++$i) {
102-
for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
103-
if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof BaseDrawing) {
104-
$file->getSlide($i)->getShapeCollection()->offsetGet($j)->setPath('zip://' . $pFilename . '#media/' . $file->getSlide($i)->getShapeCollection()->offsetGet($j)->getFilename(), false);
105-
}
106-
}
107-
}
108-
109-
$oArchive->close();
110-
return $file;
111-
}
112-
}
92+
$oArchive = new \ZipArchive();
93+
if ($oArchive->open($pFilename) === true) {
94+
$xmlContent = $oArchive->getFromName('PHPPowerPoint.xml');
95+
96+
if (!empty($xmlContent)) {
97+
$xmlData = simplexml_load_string($xmlContent);
98+
$file = unserialize(base64_decode((string) $xmlData->data));
99+
100+
// Update media links
101+
for ($i = 0; $i < $file->getSlideCount(); ++$i) {
102+
for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
103+
if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof BaseDrawing) {
104+
$file->getSlide($i)->getShapeCollection()->offsetGet($j)->setPath('zip://' . $pFilename . '#media/' . $file->getSlide($i)->getShapeCollection()->offsetGet($j)->getFilename(), false);
105+
}
106+
}
107+
}
108+
109+
$oArchive->close();
110+
return $file;
111+
}
112+
}
113113
}
114114
}

src/PhpPowerpoint/Shape/MemoryDrawing.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ public function getIndexedFilename()
178178

179179
public function getExtension()
180180
{
181-
$extension = strtolower($this->getMimeType());
182-
$extension = explode('/', $extension);
183-
return $extension[1];
181+
$extension = strtolower($this->getMimeType());
182+
$extension = explode('/', $extension);
183+
return $extension[1];
184184
}
185185

186186
/**

src/PhpPowerpoint/Writer/ODPresentation/Manifest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ public function writeManifest()
125125
private function getImageMimeType($pFile = '')
126126
{
127127
if (File::fileExists($pFile)) {
128-
if(strpos($pFile, 'zip://') === 0){
129-
$pZIPFile = str_replace('zip://', '', $pFile);
130-
$pZIPFile = substr($pZIPFile, 0, strpos($pZIPFile, '#'));
131-
$pImgFile = substr($pFile, strpos($pFile, '#') + 1);
132-
$oArchive = new \ZipArchive();
133-
$oArchive->open($pZIPFile);
134-
$image = getimagesizefromstring($oArchive->getFromName($pImgFile));
135-
} else {
136-
$image = getimagesize($pFile);
137-
}
128+
if (strpos($pFile, 'zip://') === 0){
129+
$pZIPFile = str_replace('zip://', '', $pFile);
130+
$pZIPFile = substr($pZIPFile, 0, strpos($pZIPFile, '#'));
131+
$pImgFile = substr($pFile, strpos($pFile, '#') + 1);
132+
$oArchive = new \ZipArchive();
133+
$oArchive->open($pZIPFile);
134+
$image = getimagesizefromstring($oArchive->getFromName($pImgFile));
135+
} else {
136+
$image = getimagesize($pFile);
137+
}
138138

139139
return image_type_to_mime_type($image[2]);
140140
} else {

src/PhpPowerpoint/Writer/PowerPoint2007/ContentTypes.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,16 @@ public function writeContentTypes(PHPPowerPoint $pPHPPowerPoint = null)
176176
private function getImageMimeType($pFile = '')
177177
{
178178
if (File::fileExists($pFile)) {
179-
if(strpos($pFile, 'zip://') === 0){
180-
$pZIPFile = str_replace('zip://', '', $pFile);
181-
$pZIPFile = substr($pZIPFile, 0, strpos($pZIPFile, '#'));
182-
$pImgFile = substr($pFile, strpos($pFile, '#') + 1);
183-
$oArchive = new \ZipArchive();
184-
$oArchive->open($pZIPFile);
185-
$image = getimagesizefromstring($oArchive->getFromName($pImgFile));
186-
} else {
187-
$image = getimagesize($pFile);
188-
}
179+
if (strpos($pFile, 'zip://') === 0) {
180+
$pZIPFile = str_replace('zip://', '', $pFile);
181+
$pZIPFile = substr($pZIPFile, 0, strpos($pZIPFile, '#'));
182+
$pImgFile = substr($pFile, strpos($pFile, '#') + 1);
183+
$oArchive = new \ZipArchive();
184+
$oArchive->open($pZIPFile);
185+
$image = getimagesizefromstring($oArchive->getFromName($pImgFile));
186+
} else {
187+
$image = getimagesize($pFile);
188+
}
189189

190190
return image_type_to_mime_type($image[2]);
191191
} else {

0 commit comments

Comments
 (0)