Skip to content

Commit 5d13870

Browse files
committed
Update ConsoleTable.php
1 parent 1dac380 commit 5d13870

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/Ubiquity/devtools/cmd/ConsoleTable.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ private function getCellOutput($index, $row = null) {
8383
$output .= ($this->v_lines[$index] == 1) ? $this->getVLine() : ' ';
8484

8585
$output .= $padding; // left padding
86-
if (is_string($cell)) {
87-
$cell = rtrim(preg_replace('/\s+/', ' ', $cell)); // remove line breaks
86+
if (\is_string($cell)) {
87+
$cell = \rtrim(\preg_replace('/\s+/', ' ', $cell)); // remove line breaks
8888
if (! $this->preserveSpaceBefore) {
89-
$cell = ltrim($cell);
89+
$cell = \ltrim($cell);
9090
}
9191
} else {
9292
$cell = '{}';
9393
}
94-
$content = preg_replace('#\x1b[[][^A-Za-z]*[A-Za-z]#', '', $cell);
94+
$content = \preg_replace('#\x1b[[][^A-Za-z]*[A-Za-z]#', '', $cell);
9595

9696
$delta = - \mb_strlen($cell, 'UTF-8') + \mb_strlen($content, 'UTF-8') + $this->padding;
9797
$output .= $this->mb_str_pad($cell, $width - $delta, $row ? ' ' : '-'); // cell content
9898

99-
if ($row && $index == count($row) - 1) {
100-
$output .= ($this->v_lines[count($row)] == 1) ? $this->getVLine() : ' ';
99+
if ($row && $index == \count($row) - 1) {
100+
$output .= ($this->v_lines[\count($row)] == 1) ? $this->getVLine() : ' ';
101101
}
102102
return $output;
103103
}
@@ -107,7 +107,7 @@ private function getVLine() {
107107
}
108108

109109
private function initializeBorders() {
110-
$this->h_lines = array_fill(0, sizeof($this->datas) + 1, 1);
110+
$this->h_lines = array_fill(0, \count($this->datas) + 1, 1);
111111
$this->v_lines = array_fill(0, $this->colCount + 1, 1);
112112
}
113113

@@ -123,7 +123,7 @@ private function initializeBorders() {
123123
* @return string
124124
*/
125125
private function mb_str_pad($str, $pad_len, $pad_str = ' ', $dir = STR_PAD_RIGHT, $encoding = NULL) {
126-
$content = preg_replace('#\x1b[[][^A-Za-z]*[A-Za-z]#', '', $str);
126+
$content = \preg_replace('#\x1b[[][^A-Za-z]*[A-Za-z]#', '', $str);
127127
$str_len = \mb_strlen($content);
128128
$pad_str_len = \mb_strlen($pad_str);
129129
if (! $str_len && ($dir == STR_PAD_RIGHT || $dir == STR_PAD_LEFT)) {
@@ -134,17 +134,17 @@ private function mb_str_pad($str, $pad_len, $pad_str = ' ', $dir = STR_PAD_RIGHT
134134
}
135135

136136
$result = null;
137-
$repeat = ceil($str_len - $pad_str_len + $pad_len);
137+
$repeat = \ceil($str_len - $pad_str_len + $pad_len);
138138
if ($dir == STR_PAD_RIGHT) {
139-
$result = $str . str_repeat($pad_str, $repeat);
139+
$result = $str . \str_repeat($pad_str, $repeat);
140140
$result = \mb_substr($result, 0, $pad_len);
141141
} else if ($dir == STR_PAD_LEFT) {
142142
$result = str_repeat($pad_str, $repeat) . $str;
143143
$result = \mb_substr($result, - $pad_len);
144144
} else if ($dir == STR_PAD_BOTH) {
145145
$length = ($pad_len - $str_len) / 2;
146-
$repeat = ceil($length / $pad_str_len);
147-
$result = \mb_substr(str_repeat($pad_str, $repeat), 0, floor($length)) . $str . \mb_substr(str_repeat($pad_str, $repeat), 0, ceil($length));
146+
$repeat = \ceil($length / $pad_str_len);
147+
$result = \mb_substr(str_repeat($pad_str, $repeat), 0, \floor($length)) . $str . \mb_substr(\str_repeat($pad_str, $repeat), 0, ceil($length));
148148
}
149149

150150
return $result;
@@ -160,7 +160,7 @@ public function setDatas($datas) {
160160
public function factorize() {
161161
$flag = [];
162162
foreach ($this->datas as $y => &$row) {
163-
if (is_array($row)) {
163+
if (\is_array($row)) {
164164
$index = 0;
165165
foreach ($row as &$col) {
166166
if ((isset($flag[$index]) && $col !== $flag[$index]) || ! isset($flag[$index])) {
@@ -207,7 +207,7 @@ public function getTable() {
207207
}
208208
$y ++;
209209
}
210-
$res .= $this->border(sizeof($this->datas)) . PHP_EOL;
210+
$res .= $this->border(\count($this->datas)) . PHP_EOL;
211211
return $res;
212212
}
213213

@@ -218,7 +218,7 @@ public function removeVGrid($start = 2) {
218218
}
219219

220220
public function removeHGrid($start = 2) {
221-
$size = sizeof($this->datas);
221+
$size = \count($this->datas);
222222
for ($i = $start; $i < $size; $i ++) {
223223
$this->h_lines[$i] = 0;
224224
}
@@ -231,10 +231,10 @@ public function removeGrid($hStart = 2, $vStart = 2) {
231231

232232
private function border($row) {
233233
$line = ($this->h_lines[$row]) ? self::H_LINE : ' ';
234-
$res = str_repeat(' ', $this->indent);
234+
$res = \str_repeat(' ', $this->indent);
235235
for ($i = 0; $i < $this->colCount; $i ++) {
236236
$res .= $this->getBorderValue($row, $i);
237-
$res .= str_repeat($line, $this->colWidths[$i]);
237+
$res .= \str_repeat($line, $this->colWidths[$i]);
238238
}
239239
$res .= $this->getBorderValue($row, $this->colCount);
240240
return ConsoleFormatter::colorize($res, $this->borderColor);
@@ -293,9 +293,9 @@ private function calculateColWidths() {
293293
$colCount = 0;
294294
$y = 0;
295295
foreach ($this->datas as $row) {
296-
if (is_array($row)) {
297-
if (sizeof($row) > $colCount) {
298-
$colCount = sizeof($row);
296+
if (\is_array($row)) {
297+
if (\count($row) > $colCount) {
298+
$colCount = \count($row);
299299
}
300300
$index = 0;
301301
$this->rowHeight[$y] = 1;
@@ -304,8 +304,8 @@ private function calculateColWidths() {
304304
$col = \Ubiquity\utils\base\UDateTime::elapsed($col);
305305
}
306306
if (\is_scalar($col) || (\is_object($col) && \method_exists($col, '__toString'))) {
307-
$lines = explode("\n", $col);
308-
$size = sizeof($lines);
307+
$lines = \explode("\n", $col);
308+
$size = \count($lines);
309309
if ($size > $this->rowHeight[$y]) {
310310
$this->rowHeight[$y] = $size;
311311
}
@@ -327,7 +327,7 @@ private function calculateColWidths() {
327327
$y ++;
328328
}
329329
$this->colCount = $colCount;
330-
$this->rowCount = sizeof($this->datas);
330+
$this->rowCount = \count($this->datas);
331331
return $this->colWidths;
332332
}
333333

0 commit comments

Comments
 (0)