From 66396a5198226473d9565cefb43191070ea8072b Mon Sep 17 00:00:00 2001 From: Michael Contento Date: Sun, 5 Oct 2025 18:27:09 +0200 Subject: [PATCH 1/2] Add Stringable::doesntContain() method This adds the missing doesntContain() method to the Stringable class to provide symmetry with the contains() method. The method proxies to the existing Str::doesntContain() implementation. --- src/Illuminate/Support/Stringable.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index a8b116b80e62..e24e7bc20f7a 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -222,6 +222,18 @@ public function containsAll($needles, $ignoreCase = false) return Str::containsAll($this->value, $needles, $ignoreCase); } + /** + * Determine if a given string doesn't contain a given substring. + * + * @param string|iterable $needles + * @param bool $ignoreCase + * @return bool + */ + public function doesntContain($needles, $ignoreCase = false) + { + return Str::doesntContain($this->value, $needles, $ignoreCase); + } + /** * Convert the case of a string. * From b031d96ae69683959a0562841a3e62d5858ef96b Mon Sep 17 00:00:00 2001 From: Michael Contento Date: Sun, 5 Oct 2025 18:31:47 +0200 Subject: [PATCH 2/2] Add tests for Stringable::doesntContain() method Tests cover all parameter combinations including arrays, collections, case sensitivity, and edge cases. All tests pass successfully. --- tests/Support/SupportStringableTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php index 705277ffecb5..8302193c596f 100644 --- a/tests/Support/SupportStringableTest.php +++ b/tests/Support/SupportStringableTest.php @@ -848,6 +848,19 @@ public function testContainsAll() $this->assertFalse($this->stringable('taylor otwell')->containsAll(['taylor', 'xxx'])); } + public function testDoesntContain() + { + $this->assertTrue($this->stringable('taylor')->doesntContain('xxx')); + $this->assertTrue($this->stringable('taylor')->doesntContain(['xxx'])); + $this->assertTrue($this->stringable('taylor')->doesntContain(['xxx', 'yyy'])); + $this->assertTrue($this->stringable('taylor')->doesntContain(collect(['xxx', 'yyy']))); + $this->assertTrue($this->stringable('taylor')->doesntContain('')); + $this->assertFalse($this->stringable('taylor')->doesntContain('ylo')); + $this->assertFalse($this->stringable('taylor')->doesntContain('taylor')); + $this->assertFalse($this->stringable('taylor')->doesntContain(['xxx', 'ylo'])); + $this->assertFalse($this->stringable('taylor')->doesntContain(['LOR'], true)); + } + public function testParseCallback() { $this->assertEquals(['Class', 'method'], $this->stringable('Class@method')->parseCallback('foo'));