Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Dec 12, 2023
1 parent 877053c commit 8852d60
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class Console

/**
* Console margin
* @var int
* @var ?int
*/
protected int $margin = 0;
protected ?int $margin = null;

/**
* Console terminal width
Expand Down Expand Up @@ -104,10 +104,10 @@ class Console
/**
* Instantiate a new console object
*
* @param ?int $wrap
* @param int|string $margin
* @param ?int $wrap
* @param int|string|null $margin
*/
public function __construct(?int $wrap = 80, int|string $margin = 4)
public function __construct(?int $wrap = 80, int|string|null $margin = 4)
{
$height = null;
$width = null;
Expand Down Expand Up @@ -299,7 +299,7 @@ public function getMargin(): int
*/
public function getIndent(): string
{
return str_repeat(' ', $this->margin);
return str_repeat(' ', (int)$this->margin);
}

/**
Expand Down Expand Up @@ -602,7 +602,7 @@ public function line(string $char = '-', ?int $size = null, bool $newline = true
if (!empty($this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
}
}

Expand Down Expand Up @@ -633,15 +633,15 @@ public function header(
if (!empty($this->wrap) && (strlen($string) > $this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width) && (strlen($string) > $this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
} else {
$size = strlen($string);
}
} else if ($size == 'auto') {
if (!empty($this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
}
}

Expand Down Expand Up @@ -727,15 +727,15 @@ public function alert(
if (!empty($this->wrap) && (strlen($message) > $this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width) && (strlen($message) > $this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
} else {
$size = strlen($message) + ($innerPad * 2);
}
} else if ($size == 'auto') {
if (!empty($this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
}
}

Expand Down Expand Up @@ -789,15 +789,15 @@ public function alertBox(
if (!empty($this->wrap) && (strlen($message) > $this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width) && (strlen($message) > $this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
} else {
$size = strlen($message) + ($innerPad * 2);
}
} else if ($size == 'auto') {
if (!empty($this->wrap)) {
$size = $this->wrap;
} else if (!empty($this->width)) {
$size = $this->width - ($this->margin * 2);
$size = $this->width - ((int)$this->margin * 2);
}
}

Expand Down Expand Up @@ -1069,8 +1069,8 @@ public function append(?string $text = null, bool $newline = true, bool $margin
$lines = (strlen((string)$text) > $this->wrap) ?
explode(PHP_EOL, wordwrap($text, $this->wrap, PHP_EOL)) : [$text];
} else if (!empty($this->width)) {
$lines = (strlen((string)$text) > ($this->width - ($this->margin * 2))) ?
explode(PHP_EOL, wordwrap($text, ($this->width - ($this->margin * 2)), PHP_EOL)) : [$text];
$lines = (strlen((string)$text) > ($this->width - ((int)$this->margin * 2))) ?
explode(PHP_EOL, wordwrap($text, ($this->width - ((int)$this->margin * 2)), PHP_EOL)) : [$text];
} else {
$lines = [$text];
}
Expand Down

0 comments on commit 8852d60

Please sign in to comment.