| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
NullObject is not a GoF design pattern but a schema which appears frequently enough to be considered a pattern. It has the following benefits:
Methods that return an object or null should instead return an object or NullObject. NullObjects simplify boilerplate code such as if (!is_null($obj)) { $obj->callSomething(); } to just $obj->callSomething(); by eliminating the conditional check in client code.
You can also find these code on GitHub
Service.php
.. literalinclude:: Service.php :language: php :linenos:
LoggerInterface.php
.. literalinclude:: LoggerInterface.php :language: php :linenos:
PrintLogger.php
.. literalinclude:: PrintLogger.php :language: php :linenos:
NullLogger.php
.. literalinclude:: NullLogger.php :language: php :linenos:
Tests/LoggerTest.php
.. literalinclude:: Tests/LoggerTest.php :language: php :linenos:
| Back | FazBrowse Home | New Git URL |