Skip to content

Commit 2519bab

Browse files
[9.x] Add newLine to Stringable (#41622)
* Add a method to append a new line. * Add test.
1 parent 8730e67 commit 2519bab

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Illuminate/Support/Stringable.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public function append(...$values)
6464
return new static($this->value.implode('', $values));
6565
}
6666

67+
/**
68+
* Append a new line to the string.
69+
*
70+
* @return $this
71+
*/
72+
public function newLine()
73+
{
74+
return $this->append(PHP_EOL);
75+
}
76+
6777
/**
6878
* Transliterate a UTF-8 value to ASCII.
6979
*

tests/Support/SupportStringableTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ public function testAscii()
419419
$this->assertSame('u', (string) $this->stringable('ü')->ascii());
420420
}
421421

422+
public function testNewLine()
423+
{
424+
$this->assertSame('Laravel'.PHP_EOL, (string) $this->stringable('Laravel')->newLine());
425+
}
426+
422427
public function testAsciiWithSpecificLocale()
423428
{
424429
$this->assertSame('h H sht Sht a A ia yo', (string) $this->stringable('х Х щ Щ ъ Ъ иа йо')->ascii('bg'));

0 commit comments

Comments
 (0)