Skip to content

Commit

Permalink
Fixed several CS-Fixer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hazington committed Jan 3, 2023
1 parent 050802b commit 0f6fbf2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 83 deletions.
55 changes: 10 additions & 45 deletions src/PhpWord/Style/TextBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license https://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

Expand Down Expand Up @@ -72,19 +73,14 @@ class TextBox extends Image

/**
* Set background color.
*
* @param null|string $value
* @return void
*/
public function setBgColor(string $value = null): void
public function setBgColor(?string $value = null): void
{
$this->bgColor = $value;
}

/**
* Get background color.
*
* @return null|string
*/
public function getBgColor(): ?string
{
Expand All @@ -93,19 +89,14 @@ public function getBgColor(): ?string

/**
* Set margin top.
*
* @param null|int $value
* @return void
*/
public function setInnerMarginTop(int $value = null): void
public function setInnerMarginTop(?int $value = null): void
{
$this->innerMarginTop = $value;
}

/**
* Get margin top.
*
* @return null|int
*/
public function getInnerMarginTop(): ?int
{
Expand All @@ -114,19 +105,14 @@ public function getInnerMarginTop(): ?int

/**
* Set margin left.
*
* @param null|int $value
* @return void
*/
public function setInnerMarginLeft(int $value = null): void
public function setInnerMarginLeft(?int $value = null): void
{
$this->innerMarginLeft = $value;
}

/**
* Get margin left.
*
* @return null|int
*/
public function getInnerMarginLeft(): ?int
{
Expand All @@ -135,19 +121,14 @@ public function getInnerMarginLeft(): ?int

/**
* Set margin right.
*
* @param null|int $value
* @return void
*/
public function setInnerMarginRight(int $value = null): void
public function setInnerMarginRight(?int $value = null): void
{
$this->innerMarginRight = $value;
}

/**
* Get margin right.
*
* @return null|int
*/
public function getInnerMarginRight(): ?int
{
Expand All @@ -156,19 +137,14 @@ public function getInnerMarginRight(): ?int

/**
* Set margin bottom.
*
* @param null|int $value
* @return void
*/
public function setInnerMarginBottom(int $value = null): void
public function setInnerMarginBottom(?int $value = null): void
{
$this->innerMarginBottom = $value;
}

/**
* Get margin bottom.
*
* @return null|int
*/
public function getInnerMarginBottom(): ?int
{
Expand All @@ -179,9 +155,8 @@ public function getInnerMarginBottom(): ?int
* Set TLRB cell margin.
*
* @param null|int $value Margin in twips
* @return void
*/
public function setInnerMargin(int $value = null): void
public function setInnerMargin(?int $value = null): void
{
$this->setInnerMarginTop($value);
$this->setInnerMarginLeft($value);
Expand All @@ -201,8 +176,6 @@ public function getInnerMargin(): array

/**
* Has inner margin?
*
* @return bool
*/
public function hasInnerMargins(): bool
{
Expand All @@ -222,38 +195,30 @@ public function hasInnerMargins(): bool
* Set border size.
*
* @param null|int $value Size in points
* @return void
*/
public function setBorderSize(int $value = null): void
public function setBorderSize(?int $value = null): void
{
$this->borderSize = $value;
}

/**
* Get border size.
*
* @return int
*/
public function getBorderSize(): int
public function getBorderSize(): ?int
{
return $this->borderSize;
}

/**
* Set border color.
*
* @param null|string $value
* @return void
*/
public function setBorderColor(string $value = null): void
public function setBorderColor(?string $value = null): void
{
$this->borderColor = $value;
}

/**
* Get border color.
*
* @return null|string
*/
public function getBorderColor(): ?string
{
Expand Down
5 changes: 3 additions & 2 deletions src/PhpWord/Writer/Word2007/Element/TextBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license https://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

Expand All @@ -30,13 +31,13 @@ public function write(): void
{
$xmlWriter = $this->getXmlWriter();
$element = $this->getElement();
if (! $element instanceof \PhpOffice\PhpWord\Element\TextBox) {
if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) {
return;
}
$style = $element->getStyle();
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);

if (! $this->withoutP) {
if (!$this->withoutP) {
$xmlWriter->startElement('w:p');
$styleWriter->writeAlignment();
}
Expand Down
5 changes: 3 additions & 2 deletions src/PhpWord/Writer/Word2007/Style/TextBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license https://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

Expand All @@ -29,7 +30,7 @@ class TextBox extends Frame
public function writeInnerMargin(): void
{
$style = $this->getStyle();
if (! $style instanceof TextBoxStyle || ! $style->hasInnerMargins()) {
if (!$style instanceof TextBoxStyle || !$style->hasInnerMargins()) {
return;
}

Expand All @@ -45,7 +46,7 @@ public function writeInnerMargin(): void
public function writeBorder(): void
{
$style = $this->getStyle();
if (! $style instanceof TextBoxStyle) {
if (!$style instanceof TextBoxStyle) {
return;
}
$xmlWriter = $this->getXmlWriter();
Expand Down
69 changes: 35 additions & 34 deletions tests/PhpWordTests/Style/TextBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license https://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

Expand All @@ -35,24 +36,24 @@ public function testSetGetNormal(): void
$object = new TextBox();

$properties = [
'width' => 200,
'height' => 200,
'alignment' => Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
'positioning' => 'absolute',
'posHorizontal' => 'center',
'posVertical' => 'top',
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page',
'innerMarginTop' => '5',
'innerMarginRight' => '5',
'width' => 200,
'height' => 200,
'alignment' => Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
'positioning' => 'absolute',
'posHorizontal' => 'center',
'posVertical' => 'top',
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page',
'innerMarginTop' => '5',
'innerMarginRight' => '5',
'innerMarginBottom' => '5',
'innerMarginLeft' => '5',
'borderSize' => '2',
'borderColor' => 'red',
'bgColor' => 'blue',
'innerMarginLeft' => '5',
'borderSize' => '2',
'borderColor' => 'red',
'bgColor' => 'blue',
];
foreach ($properties as $key => $value) {
$set = "set{$key}";
Expand All @@ -70,24 +71,24 @@ public function testSetStyleValue(): void
$object = new TextBox();

$properties = [
'width' => 200,
'height' => 200,
'alignment' => Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
'positioning' => 'absolute',
'posHorizontal' => 'center',
'posVertical' => 'top',
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page',
'innerMarginTop' => '5',
'innerMarginRight' => '5',
'width' => 200,
'height' => 200,
'alignment' => Jc::START,
'marginTop' => 240,
'marginLeft' => 240,
'wrappingStyle' => 'inline',
'positioning' => 'absolute',
'posHorizontal' => 'center',
'posVertical' => 'top',
'posHorizontalRel' => 'margin',
'posVerticalRel' => 'page',
'innerMarginTop' => '5',
'innerMarginRight' => '5',
'innerMarginBottom' => '5',
'innerMarginLeft' => '5',
'borderSize' => '2',
'borderColor' => 'red',
'bgColor' => 'blue',
'innerMarginLeft' => '5',
'borderSize' => '2',
'borderColor' => 'red',
'bgColor' => 'blue',
];
foreach ($properties as $key => $value) {
$get = "get{$key}";
Expand Down

0 comments on commit 0f6fbf2

Please sign in to comment.