Skip to content

Commit 254d300

Browse files
authored
Merge pull request #1511 from carusogabriel/ternary-expressions
Remove unnecessary ternary expressions
2 parents 8ffaa1c + 3cf0770 commit 254d300

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/PhpWord/Metadata/DocInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public static function convertProperty($propertyValue, $propertyType)
507507
case 'date': // Date
508508
return strtotime($propertyValue);
509509
case 'bool': // Boolean
510-
return ($propertyValue == 'true') ? true : false;
510+
return $propertyValue == 'true';
511511
}
512512

513513
return $propertyValue;

src/PhpWord/Reader/MsDoc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ private function readPrl($data, $pos, $cbNum)
16191619
break;
16201620
// sprmCFData
16211621
case 0x06:
1622-
$sprmCFData = dechex($operand) == 0x00 ? false : true;
1622+
$sprmCFData = dechex($operand) != 0x00;
16231623
break;
16241624
// sprmCFItalic
16251625
case 0x36:

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent
338338
} elseif ('w:tr' == $tblNode->nodeName) { // Row
339339
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
340340
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
341-
$rowHRule = $rowHRule == 'exact' ? true : false;
341+
$rowHRule = $rowHRule == 'exact';
342342
$rowStyle = array(
343343
'tblHeader' => $xmlReader->elementExists('w:trPr/w:tblHeader', $tblNode),
344344
'cantSplit' => $xmlReader->elementExists('w:trPr/w:cantSplit', $tblNode),

src/PhpWord/Shared/ZipArchive.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function pclzipAddFile($filename, $localname = null)
258258
unlink($this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']);
259259
}
260260

261-
return ($res == 0) ? false : true;
261+
return $res != 0;
262262
}
263263

264264
/**
@@ -289,7 +289,7 @@ public function pclzipAddFromString($localname, $contents)
289289
// Remove temp file
290290
@unlink($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']);
291291

292-
return ($res == 0) ? false : true;
292+
return $res != 0;
293293
}
294294

295295
/**
@@ -309,7 +309,7 @@ public function pclzipExtractTo($destination, $entries = null)
309309
if (is_null($entries)) {
310310
$result = $zip->extract(PCLZIP_OPT_PATH, $destination);
311311

312-
return ($result > 0) ? true : false;
312+
return $result > 0;
313313
}
314314

315315
// Extract by entries

tests/PhpWord/_includes/XmlDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function elementExists($path, $file = 'word/document.xml')
163163
{
164164
$nodeList = $this->getNodeList($path, $file);
165165

166-
return !($nodeList->length == 0);
166+
return $nodeList->length != 0;
167167
}
168168

169169
/**

0 commit comments

Comments
 (0)