Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teodoroleckie/value-object
⚡ Library to implement value-object / nullable-value-object in PHP
https://github.com/teodoroleckie/value-object
nullable-value-object nullable-valueobject php php-8 php8 value-object valueobject
Last synced: about 1 month ago
JSON representation
⚡ Library to implement value-object / nullable-value-object in PHP
- Host: GitHub
- URL: https://github.com/teodoroleckie/value-object
- Owner: teodoroleckie
- License: mit
- Created: 2021-05-08T10:13:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-13T08:47:11.000Z (over 3 years ago)
- Last Synced: 2024-09-29T20:03:19.105Z (about 2 months ago)
- Topics: nullable-value-object, nullable-valueobject, php, php-8, php8, value-object, valueobject
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Library to implement value-object / nullable-value-object in PHP
[![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)
[![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)
[![Total Downloads](https://img.shields.io/packagist/dt/tleckie/value-object.svg?style=flat-square)](https://packagist.org/packages/tleckie/value-object)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/teodoroleckie/value-object/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)### Create your own value-object type:
You should only extend from the ValueObject class
```php
equals($mario); // true$john->equals($raquel); // false
$john->equals(new FirstName('Mario')); // false
$raquel->value(); // "34"
```### Force primitive type:
Override value() method to indicate the return primitive type.
```php
value(); // int 34$mario->equals($raquel); // true
(string)$mario; // string "34"
```
### Nullable value-object
If your object can contain null value you can extend of NullableValueObject class```php