codedruids/black-hole

Testing class that ignores everything while still being valid

v1.1 2020-08-08 04:02 UTC

This package is auto-updated.

Last update: 2024-12-08 15:03:01 UTC


README

Latest release Build Status Code Coverage Code Quality Software License

BlackHole is a PHP testing class that ignores anything done to it.

Requirements

  • PHP 5.6 or higher

Installation

Add the following to your composer.json:

{
    "require": {
        "CodeDruids/black-hole": "1.*"
    }
}

Basic Usage

$test = new \CodeDruids\BlackHole("test");

$test->a = "b";
unset($test->c);
isset($test->d)
$test->e("f");
\CodeDruids\BlackHole::g("h")
var_dump($test);
echo $test;
$test();

This can be useful when you need a placeholder object, or want the ability to switch a class alias to remove any impact on a production environment. e.g.

if (env('APP_ENV') == 'production') {
	class_alias('CodeDruids\BlackHole', 'Debug');
}
else {
	class_alias('My\Clever\Debugger', 'Debug');
}
Debug::log('Profound silence');

Support

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.