diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php
index 9fa57c5294c0..895bb9d7e194 100644
--- a/src/Illuminate/Support/Stringable.php
+++ b/src/Illuminate/Support/Stringable.php
@@ -565,6 +565,17 @@ public function start($prefix)
return new static(Str::start($this->value, $prefix));
}
+ /**
+ * Strip HTML and PHP tags from the given string.
+ *
+ * @param string $allowedTags
+ * @return static
+ */
+ public function stripTags($allowedTags = null)
+ {
+ return new static(strip_tags($this->value, $allowedTags));
+ }
+
/**
* Convert the given string to upper-case.
*
diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php
index bd3a15d01b80..c07094e00c37 100644
--- a/tests/Support/SupportStringableTest.php
+++ b/tests/Support/SupportStringableTest.php
@@ -686,4 +686,12 @@ public function testWordCount()
$this->assertEquals(2, $this->stringable('Hello, world!')->wordCount());
$this->assertEquals(10, $this->stringable('Hi, this is my first contribution to the Laravel framework.')->wordCount());
}
+
+ public function testStripTags()
+ {
+ $this->assertSame('beforeafter', (string) $this->stringable('before
after')->stripTags());
+ $this->assertSame('before
after', (string) $this->stringable('before
after')->stripTags('
'));
+ $this->assertSame('before
after', (string) $this->stringable('before
after')->stripTags('
'));
+ $this->assertSame('before
after', (string) $this->stringable('before
after')->stripTags('
'));
+ }
}