Skip to content

Commit 5a07d01

Browse files
committed
Use ctype_digit instead of is_numeric
1 parent 4049d03 commit 5a07d01

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/MenuStyle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ public function getDisabledItemText(string $text) : string
202202
*/
203203
private function generateColoursSetCode() : void
204204
{
205-
if (!is_numeric($this->fg)) {
205+
if (!ctype_digit($this->fg)) {
206206
$fgCode = self::$availableForegroundColors[$this->fg];
207207
} else {
208208
$fgCode = sprintf("38;5;%s", $this->fg);
209209
}
210210

211-
if (!is_numeric($this->bg)) {
211+
if (!ctype_digit($this->bg)) {
212212
$bgCode = self::$availableBackgroundColors[$this->bg];
213213
} else {
214214
$bgCode = sprintf("48;5;%s", $this->bg);

src/Util/ColourUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public static function map256To8(int $colourCode) : string
308308
*/
309309
public static function validateColour(Terminal $terminal, string $colour, string $fallback = null) : string
310310
{
311-
if (!is_numeric($colour)) {
311+
if (!ctype_digit($colour)) {
312312
return static::validateColourName($colour);
313313
}
314314

test/CliMenuBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function testSetBgThrowsExceptionWhenColourCodeIsNotInRange() : void
145145

146146
$builder = new CliMenuBuilder;
147147
$builder->setTerminal($terminal);
148-
$builder->setBackgroundColour(-5, 'white');
148+
$builder->setBackgroundColour(257, 'white');
149149
}
150150

151151
public function testDisableDefaultItems() : void

test/MenuStyleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function testSetBgThrowsExceptionWhenColourCodeIsNotInRange() : void
164164
$this->expectExceptionMessage('Invalid colour code');
165165

166166
$style = $this->getMenuStyle(256);
167-
$style->setBg(-5, 'white');
167+
$style->setBg(257, 'white');
168168
}
169169

170170
public function testGetMarkerReturnsTheCorrectMarkers() : void

0 commit comments

Comments
 (0)