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

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

koriym/null-object
==================

Null object generator

1.0.4(2y ago)31.6M↓20.5%13MITPHPPHP ^7.2 || ^8.0CI passing

Since Feb 12Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/koriym/Koriym.NullObject)[ Packagist](https://packagist.org/packages/koriym/null-object)[ RSS](/packages/koriym-null-object/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (3)

PHP NullObject
==============

[](#php-nullobject)

[![codecov](https://camo.githubusercontent.com/b3fe6e5f3d9d83017a96959ec9947c48ebcfccba15a33c13f0b2bbd1ea00b7b8/68747470733a2f2f636f6465636f762e696f2f67682f6b6f7269796d2f4b6f7269796d2e4e756c6c4f626a6563742f6272616e63682f312e782f67726170682f62616467652e7376673f746f6b656e3d43787258356d51544246)](https://codecov.io/gh/koriym/Koriym.NullObject)[![Type Coverage](https://camo.githubusercontent.com/23ecb29ac4ac1c9437fb30445fae2b190589ef09ec0604c280b8d3f526ee1ead/68747470733a2f2f73686570686572642e6465762f6769746875622f7261792d64692f5261792e416f702f636f7665726167652e737667)](https://shepherd.dev/github/ray-di/Ray.Aop)[![Continuous Integration](https://github.com/koriym/Koriym.NullObject/workflows/Continuous%20Integration/badge.svg)](https://github.com/koriym/Koriym.NullObject/workflows/Continuous%20Integration/badge.svg)

Generates a NullObject from an interface. It was created for testing and AOP.

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

[](#installation)

```
composer require --dev koriym/null-object

```

Getting Started
---------------

[](#getting-started)

Instantiate a Null Object from an Interface.

```
interface FooInterface
{
   public function do(): void;
}
```

```
$nullObject = $this->nullObject->newInstance(FooInterface::class);
assert($nullObject instanceof FooInterface);
$nullObject->do(); // nothing's going to happen
```

`newInstance()` defines a class with `eval`, but use `save()` to save the generated code to a file.

```
$class = $this->nullObject->save(FooInterface::class, '/path/to/saveDirectory');
assert(new $class instanceof FooInterface);
```

On the fly
----------

[](#on-the-fly)

It is also possible to create a null object by simply adding a `Null` suffix to the interface by registering autoloader, If this doesn't sound too wild to you.

```
$loader = require __DIR__ . '/vendor/koriym/null-object/autoload.php';
spl_autoload_register($loader);
```

or add it to `autoload-dev` in composer.json.

```
    "autoload-dev": {
        "files": ["./vendor/koriym/null-object/autoload.php"]
    }
```

You can create Null Object as follows.

```
$nullClass = FooInterface::class . 'Null'; // add Null suffix to the interface
$foo = new $nullClass;  // instantiate a NullObject
assert($foo instanceof FooInterface);
```

Note
----

[](#note)

Inherited interfaces are not yet supported.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance53

Moderate activity, may be stable

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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

Every ~300 days

Recently: every ~330 days

Total

7

Last Release

118d ago

Major Versions

0.1.0 → 1.0.02021-08-13

### Community

Maintainers

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

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (92 commits)")[![NaokiTsuchiya](https://avatars.githubusercontent.com/u/17171732?v=4)](https://github.com/NaokiTsuchiya "NaokiTsuchiya (4 commits)")

---

Tags

nullobject

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[zhuzhichao/bank-card-info

Get the bank card info

45464.8k](/packages/zhuzhichao-bank-card-info)

PHPackages © 2026

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