BlackHole is a PHP testing class that ignores anything done to it.
- PHP 5.6 or higher
Add the following to your composer.json
:
{
"require": {
"CodeDruids/black-hole": "1.*"
}
}
$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');
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.