Skip to content

Commit 38788e0

Browse files
committed
Code style
1 parent 889f4e3 commit 38788e0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/PhpWord/Shared/Html.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ protected static function parseInlineStyle($node, $styles = array())
109109
break;
110110
case 'width':
111111
// tables, cells
112-
if(false !== strpos($val, '%')){
113-
// e.g. <table width="100%"> or <td width=50%>
112+
if (false !== strpos($val, '%')) {
113+
// e.g. <table width="100%"> or <td width="50%">
114114
$styles['width'] = intval($val) * 50;
115115
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT;
116-
}else{
116+
} else {
117117
// e.g. <table width="250> where "250" = 250px (always pixels)
118118
$styles['width'] = Converter::pixelToTwip($val);
119119
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::TWIP;
@@ -472,10 +472,10 @@ protected static function parseList($node, $element, &$styles, &$data)
472472
$levels = $style->getLevels();
473473
/** @var \PhpOffice\PhpWord\Style\NumberingLevel */
474474
$level = $levels[0];
475-
if($start > 0){
475+
if ($start > 0) {
476476
$level->setStart($start);
477477
}
478-
if($type && !!($type = self::mapListType($type))){
478+
if ($type && !!($type = self::mapListType($type))) {
479479
$level->setFormat($type);
480480
}
481481
}
@@ -675,10 +675,10 @@ protected static function parseStyle($attribute, $styles)
675675
// must have exact order [width color style], e.g. "1px #0011CC solid" or "2pt green solid"
676676
// Word does not accept shortened hex colors e.g. #CCC, only full e.g. #CCCCCC
677677
if (preg_match('/([0-9]+[^0-9]*)\s+(\#[a-fA-F0-9]+|[a-zA-Z]+)\s+([a-z]+)/', $cValue, $matches)) {
678-
if(false !== strpos($cKey, '-')){
678+
if (false !== strpos($cKey, '-')) {
679679
$which = explode('-', $cKey)[1];
680680
$which = ucfirst($which); // e.g. bottom -> Bottom
681-
}else{
681+
} else {
682682
$which = '';
683683
}
684684
// normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
@@ -883,6 +883,10 @@ protected static function mapAlignVertical($alignment)
883883
case 'baseline':
884884
return 'top';
885885
default:
886+
// @discuss - which one should apply:
887+
// - Word uses default vert. alignment: top
888+
// - all browsers use default vert. alignment: middle
889+
// Returning empty string means attribute wont be set so use Word default (top).
886890
return '';
887891
}
888892
}

0 commit comments

Comments
 (0)