{"id":15027132,"url":"https://github.com/teodoroleckie/value-object","last_synced_at":"2026-01-29T03:36:38.573Z","repository":{"id":57070528,"uuid":"365482271","full_name":"teodoroleckie/value-object","owner":"teodoroleckie","description":"⚡ Library to implement value-object / nullable-value-object in PHP","archived":false,"fork":false,"pushed_at":"2021-05-13T08:47:11.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T20:28:26.780Z","etag":null,"topics":["nullable-value-object","nullable-valueobject","php","php-8","php8","value-object","valueobject"],"latest_commit_sha":null,"homepage":"","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/teodoroleckie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["teodoroleckie"],"custom":["https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"]}},"created_at":"2021-05-08T10:13:47.000Z","updated_at":"2022-08-03T11:36:22.000Z","dependencies_parsed_at":"2022-08-24T14:54:23.040Z","dependency_job_id":null,"html_url":"https://github.com/teodoroleckie/value-object","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fvalue-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fvalue-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fvalue-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Fvalue-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teodoroleckie","download_url":"https://codeload.github.com/teodoroleckie/value-object/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330319,"owners_count":20274039,"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":["nullable-value-object","nullable-valueobject","php","php-8","php8","value-object","valueobject"],"created_at":"2024-09-24T20:05:49.862Z","updated_at":"2026-01-29T03:36:33.544Z","avatar_url":"https://github.com/teodoroleckie.png","language":"PHP","readme":"# Library to implement value-object / nullable-value-object in PHP\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teodoroleckie/value-object/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/value-object/?branch=main)\n[![Build Status](https://scrutinizer-ci.com/g/teodoroleckie/value-object/badges/build.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/value-object/build-status/main)\n[![Total Downloads](https://img.shields.io/packagist/dt/tleckie/value-object.svg?style=flat-square)](https://packagist.org/packages/tleckie/value-object)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/teodoroleckie/value-object/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)\n\n\n### Create your own value-object type:\nYou should only extend from the ValueObject class\n```php\n\u003c?php\n\n/**\n * Class Age\n */\nclass Age extends ValueObject\n{\n\n}\n```\n\n### Compare value-objects:\n```php\n\u003c?php\n\n/**\n * Class Age\n */\nclass Age extends ValueObject\n{\n\n}\n\n$john = new Age(34);\n$mario = new Age(34);\n$raquel = new Age(\"34\");\n\n\n$john-\u003eequals($mario);  // true\n\n$john-\u003eequals($raquel); // false\n\n$john-\u003eequals(new FirstName('Mario')); // false\n\n$raquel-\u003evalue();       // \"34\"\n```\n\n### Force primitive type:\nOverride value() method to indicate the return primitive type.\n```php\n\u003c?php\n\n/**\n * Class Age\n */\nclass Age extends ValueObject\n{\n    /**\n    * @return int\n    */\n    public function value(): int\n    {\n        return parent::value();\n    }\n}\n\n$raquel = new Age(\"34\");\n$mario = new Age(34);\n\n$raquel-\u003evalue();        // int 34\n\n$mario-\u003eequals($raquel); // true\n\n(string)$mario;          // string \"34\"\n\n```\n\n### Nullable value-object\nIf your object can contain null value you can extend of NullableValueObject class\n\n```php\n\u003c?php\n\n/**\n * Class Age\n */\nclass Age extends NullableValueObject\n{\n\n}\n\n// That's all! I hope this helps you\n\n```\n\n","funding_links":["https://github.com/sponsors/teodoroleckie","https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Fvalue-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteodoroleckie%2Fvalue-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Fvalue-object/lists"}