承接 stratdes/vo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stratdes/vo

最新稳定版本:2.0.0

Composer 安装命令:

composer require stratdes/vo

包简介

Generic ValueObjects library

README 文档

README

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('email1@mail.com'));
$emailCollection->add(Email::fromValue('email2@mail.com'));
$emailCollection->add(Email::fromValue('email3@mail.com'));

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.

统计信息

  • 总下载量: 4.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-24