hyperized/value-objects 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hyperized/value-objects

最新稳定版本:v0.5.0

Composer 安装命令:

composer require hyperized/value-objects

包简介

A basic value objects collection

README 文档

README

FOSSA Status

A basic PHP value objects collection.

Install

composer require hyperized/value-objects

Examples

Integer type

<?php declare(strict_types=1);

use Hyperized\ValueObjects\Abstracts\Integers\AbstractInteger;

include 'vendor/autoload.php';

// Implement concrete class for as value object
class MyObject extends AbstractInteger {}

$myObject = MyObject::fromInteger(1337);

var_dump($myObject->getValue()); // int(1337)

Other types that are offered:

  • NegativeInteger.
    • Validates value is below 0 (zero).
  • PositiveInteger
    • Validates value is above 0 (zero).
  • RangedInteger.
    • Validates value is higher than minimum.
    • Validates value is lower than maximum.
    • By default minimum value is PHP_INT_MIN and maximum value PHP_INT_MAX.
  • Octal.
    • Validates value is octal.

String type (ByteArray)

Strings are called ByteArrays due to string being a reserved word in PHP.

<?php declare(strict_types=1);

use Hyperized\ValueObjects\Abstracts\Strings\AbstractByteArray;

include 'vendor/autoload.php';

class MyObject extends AbstractByteArray {}

$myObject = MyObject::fromString('Hello world!');
var_dump($myObject->getValue()); // string('Hello world');

Other types that are offered:

  • EmptyByteArray.
    • Validates value equals '' (empty string)
  • NonEmptyByteArray.
    • Validates value does not equal '' (empty string)

Licence

MIT

FOSSA Status

Author

Gerben Geijteman gerben@hyperized.net

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-11