{"id":16193210,"url":"https://github.com/koriym/koriym.nullobject","last_synced_at":"2025-10-24T23:04:33.089Z","repository":{"id":38206870,"uuid":"336332323","full_name":"koriym/Koriym.NullObject","owner":"koriym","description":"A NullObject generator","archived":false,"fork":false,"pushed_at":"2025-02-15T13:56:31.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"1.x","last_synced_at":"2025-03-17T03:34:21.856Z","etag":null,"topics":["nullobject"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/koriym/null-object","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koriym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-05T16:51:00.000Z","updated_at":"2023-08-24T01:04:30.000Z","dependencies_parsed_at":"2024-06-20T23:36:40.159Z","dependency_job_id":null,"html_url":"https://github.com/koriym/Koriym.NullObject","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.048387096774193505","last_synced_commit":"2d74ffd61f8c6551cebe6b13e767abe7ad5ea52a"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2FKoriym.NullObject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2FKoriym.NullObject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2FKoriym.NullObject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koriym%2FKoriym.NullObject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koriym","download_url":"https://codeload.github.com/koriym/Koriym.NullObject/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244357330,"owners_count":20440315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nullobject"],"created_at":"2024-10-10T08:14:20.737Z","updated_at":"2025-10-24T23:04:33.071Z","avatar_url":"https://github.com/koriym.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP NullObject\n\n[![codecov](https://codecov.io/gh/koriym/Koriym.NullObject/branch/1.x/graph/badge.svg?token=CxrX5mQTBF)](https://codecov.io/gh/koriym/Koriym.NullObject)\n[![Type Coverage](https://shepherd.dev/github/ray-di/Ray.Aop/coverage.svg)](https://shepherd.dev/github/ray-di/Ray.Aop)\n![Continuous Integration](https://github.com/koriym/Koriym.NullObject/workflows/Continuous%20Integration/badge.svg)\n\n\nGenerates a NullObject from an interface.\nIt was created for testing and AOP.\n\n\n## Installation\n\n    composer require --dev koriym/null-object\n\n## Getting Started\n\nInstantiate a Null Object from an Interface.\n\n```php\ninterface FooInterface\n{\n   public function do(): void;\n}\n```\n```php\n$nullObject = $this-\u003enullObject-\u003enewInstance(FooInterface::class);\nassert($nullObject instanceof FooInterface);\n$nullObject-\u003edo(); // nothing's going to happen\n\n```\n\n`newInstance()` defines a class with `eval`, but use `save()` to save the generated code to a file.\n\n```php\n$class = $this-\u003enullObject-\u003esave(FooInterface::class, '/path/to/saveDirectory');\nassert(new $class instanceof FooInterface);\n\n```\n## On the fly\n\nIt 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.\n\n```php\n$loader = require __DIR__ . '/vendor/koriym/null-object/autoload.php';\nspl_autoload_register($loader);\n```\n\nor add it to `autoload-dev` in composer.json.\n\n```php\n    \"autoload-dev\": {\n        \"files\": [\"./vendor/koriym/null-object/autoload.php\"]\n    }\n```\n\nYou can create Null Object as follows.\n\n```php\n$nullClass = FooInterface::class . 'Null'; // add Null suffix to the interface\n$foo = new $nullClass;  // instantiate a NullObject\nassert($foo instanceof FooInterface);\n```\n\n## Note\n\nInherited interfaces are not yet supported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoriym%2Fkoriym.nullobject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoriym%2Fkoriym.nullobject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoriym%2Fkoriym.nullobject/lists"}