PHPackages                             atournayre/null - 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. atournayre/null

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

atournayre/null
===============

Provides a null object

029PHP

Since Jun 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/atournayre/null)[ Packagist](https://packagist.org/packages/atournayre/null)[ RSS](/packages/atournayre-null/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Null
====

[](#null)

This package provides a way to handle nullable values in your application.

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

```
$ composer require atournayre/null

```

### Usage

[](#usage)

Title is from the Fixture namespace in Tests.

#### Nominal case

[](#nominal-case)

Before you used to have return type `string` and now you can use `Title` object.

```
$title = Title::create('My title');

$title->title; // 'My title'
$title->isNull(); // false
$title->isNotNull(); // true
```

#### Nullable case

[](#nullable-case)

Before you used to have return type `null` and now you can use `Title` object.

```
$title = Title::asNull();

$title->title; // 'Empty title'
$title->isNull(); // true
$title->isNotNull(); // false
```

#### Maybe nullable case

[](#maybe-nullable-case)

Before you used to have return type `?string` and now you can use `Title` object.

If you are not sure if the value is null or not, you can use `orNull()` method, it's a replacement of `?->` operator.

```
$title = Title::create('My title')
    ->orNull()
    ->title; // 'My title'
```

```
$title = Title::asNull()
    ->orNull()
    ->title; // 'Empty title'
```

Instead of using `orNull()` method, you can use `orThrow()` method to throw an exception if the value is null.

```
$title = Title::asNull()
    ->orThrow(new \RuntimeException('Title is null'));
```

`orThrow()` also accepts a callable to throw an exception with a custom message.

```
$title = Title::asNull()
    ->orThrow(fn () => new \RuntimeException('Title is null'));
```

Contributing
------------

[](#contributing)

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

After writing your fix/feature, you can run following commands to make sure that everything is still ok.

```
# Install dev dependencies
$ composer install

# Running tests and quality tools locally
$ make all
```

Authors
-------

[](#authors)

- [Aurélien Tournayre](https://github.com/atournayre) -

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/be702ea3d10de6d97d83c32866fc9cfe1830a055e7f8b685c8434ccad40416c1?d=identicon)[atournayre](/maintainers/atournayre)

---

Top Contributors

[![atournayre](https://avatars.githubusercontent.com/u/4262077?v=4)](https://github.com/atournayre "atournayre (9 commits)")

---

Tags

nullphp

### Embed Badge

![Health badge](/badges/atournayre-null/health.svg)

```
[![Health](https://phpackages.com/badges/atournayre-null/health.svg)](https://phpackages.com/packages/atournayre-null)
```

###  Alternatives

[azuracast/azuracast

The AzuraCast self-hosted web radio station management suite.

3.9k27.8k](/packages/azuracast-azuracast)[bangnokia/laravel-serve-livereload

Bring livereload to laravel artisan serve command

1008.9k](/packages/bangnokia-laravel-serve-livereload)[mediawiki/semantic-bundle

Bundle extension that installs and loads Semantic MediaWiki and associated extensions

204.4k](/packages/mediawiki-semantic-bundle)

PHPackages © 2026

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