Skip to content

stratdes/vo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrutinizer Code Quality Build Status Code Coverage

StraTDeS VO library

StraTDeS VO is a library containing some standard value objects ready to use.

Installation

To install the library just run:

composer require stratdes/vo

Usage

Using this library is quite straightforward. All the Value Objects have a named constructor, usually create or fromValue.

Some examples:

use StraTDeS\VO\Single\Currency;
use StraTDeS\VO\Single\Money;
use StraTDeS\VO\Single\Name;
use StraTDeS\VO\Single\Description;
use StraTDeS\VO\Single\PhoneNumber;

$name = Name::fromValue("John Smith");
$description = Description::fromValue("This is a description");
$money = Money::create(
    20034,
    Currency::fromValue(Currency::USD)
);
$phoneNumber = PhoneNumber::create("34", "938140000");

You can use collections, also. For example, for a collection of Emails, you have:

use StraTDeS\VO\Collection\EmailCollection;
use StraTDeS\VO\Single\Email;

$emailCollection = EmailCollection::create();

$emailCollection->add(Email::fromValue('[email protected]'));
$emailCollection->add(Email::fromValue('[email protected]'));
$emailCollection->add(Email::fromValue('[email protected]'));

foreach($emailCollection as $email) {
    echo $email->value() . "\n\r";
}

Issues

If you find some issue in the library, please feel free to open an issue here on Github.

About

Generic Value Objects library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages