Skip to content

Commit fb0e656

Browse files
authored
Merge pull request #9 from wujunze/develop
PHP_EOL is a option
2 parents 22f0d18 + ffe0c2b commit fb0e656

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Colors.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct()
6868
}
6969

7070
// Returns colored string
71-
public function getColoredString($string, $foreground_color = null, $background_color = null)
71+
public function getColoredString($string, $foreground_color = null, $background_color = null, $new_line = true)
7272
{
7373
$colored_string = "";
7474

@@ -84,7 +84,7 @@ public function getColoredString($string, $foreground_color = null, $background_
8484
// Add string and end coloring
8585
$colored_string .= $string . "\033[0m";
8686

87-
return $colored_string . PHP_EOL;
87+
return $new_line ? $colored_string . PHP_EOL : $colored_string;
8888
}
8989

9090
// Returns all foreground color names

tests/ColorTest/CliColorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ public function testColoredString()
2121
$this->assertEquals('Testing Colors class, this is purple string on yellow background.' . PHP_EOL, $res);
2222
}
2323

24+
public function testColorString()
25+
{
26+
$color = $this->createServer();
27+
$res = $color->getColoredString("Testing Colors class, this is purple string on yellow background.",
28+
"purple",
29+
"yellow",
30+
false);
31+
$this->assertEquals('Testing Colors class, this is purple string on yellow background.' , $res);
32+
33+
}
34+
2435
public function testGetBackgroundColors()
2536
{
2637
$color = $this->createServer();

0 commit comments

Comments
 (0)