PHPackages                             sumaiazaman/laravel-stringable-extras - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sumaiazaman/laravel-stringable-extras

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sumaiazaman/laravel-stringable-extras
=====================================

Missing whenDoesntContain and whenDoesntContainAll methods for Laravel's Stringable class.

v1.0.0(2mo ago)00MITPHPPHP ^8.2CI passing

Since May 22Pushed 2mo agoCompare

[ Source](https://github.com/sumaiazaman/laravel-stringable-extras)[ Packagist](https://packagist.org/packages/sumaiazaman/laravel-stringable-extras)[ RSS](/packages/sumaiazaman-laravel-stringable-extras/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Stringable Extras
=========================

[](#laravel-stringable-extras)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1993d9956810e318931c937736ff3ce10e869981b5e08f0c8d89f144071f33b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73756d6169617a616d616e2f6c61726176656c2d737472696e6761626c652d6578747261732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sumaiazaman/laravel-stringable-extras)[![Tests](https://camo.githubusercontent.com/019abeae96838d7047cba647371bc0600098c411a353924e4c61b92bc6e15a13/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73756d6169617a616d616e2f6c61726176656c2d737472696e6761626c652d6578747261732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sumaiazaman/laravel-stringable-extras/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/cb0d5abad8645a78228843b0923de11c9b6aef8fb36e80c40bcd1c4a537c03cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73756d6169617a616d616e2f6c61726176656c2d737472696e6761626c652d6578747261732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Adds the missing `whenDoesntContain()` and `whenDoesntContainAll()` methods to Laravel's fluent `Stringable` class.

Laravel ships with `whenContains()` and `whenContainsAll()`, and has negative counterparts for start/end (`whenDoesntStartWith`, `whenDoesntEndWith`), but the negative counterpart for `contains` was never added to the framework. This package fills that gap.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12, or 13

Installation
------------

[](#installation)

```
composer require sumaiazaman/laravel-stringable-extras
```

The service provider is auto-discovered — no manual registration needed.

Usage
-----

[](#usage)

### `whenDoesntContain()`

[](#whendoesntcontain)

Executes the callback when the string does **not** contain the given substring. Accepts a string or an array of strings (any match counts).

```
// Callback fires — string doesn't contain 'xxx'
$result = str('hello world')
    ->whenDoesntContain('xxx', fn ($s) => $s->upper());
// 'HELLO WORLD'

// Callback is skipped — string contains 'world'
$result = str('hello world')
    ->whenDoesntContain('world', fn ($s) => $s->upper());
// 'hello world'

// With a default callback
$result = str('hello world')
    ->whenDoesntContain(
        'world',
        fn ($s) => $s->upper(),
        fn ($s) => $s->title(),
    );
// 'Hello World'

// Array of needles — callback fires only if none are present
$result = str('hello world')
    ->whenDoesntContain(['foo', 'bar'], fn ($s) => $s->upper());
// 'HELLO WORLD'
```

### `whenDoesntContainAll()`

[](#whendoesntcontainall)

Executes the callback when the string does **not** contain all of the given substrings. If even one needle is missing, the callback fires.

```
// Callback fires — 'xxx' is not in the string
$result = str('hello world')
    ->whenDoesntContainAll(['hello', 'xxx'], fn ($s) => $s->upper());
// 'HELLO WORLD'

// Callback is skipped — both needles are present
$result = str('hello world')
    ->whenDoesntContainAll(['hello', 'world'], fn ($s) => $s->upper());
// 'hello world'
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance87

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

63d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/80034544?v=4)[sumaia161](/maintainers/sumaia161)[@Sumaia161](https://github.com/Sumaia161)

---

Top Contributors

[![sumaiazaman](https://avatars.githubusercontent.com/u/45918347?v=4)](https://github.com/sumaiazaman "sumaiazaman (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sumaiazaman-laravel-stringable-extras/health.svg)

```
[![Health](https://phpackages.com/badges/sumaiazaman-laravel-stringable-extras/health.svg)](https://phpackages.com/packages/sumaiazaman-laravel-stringable-extras)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
