2017 © Pedro Peláez
 

library value-object

Library of abstract classes intended to be used as bases for value objects.

image

jakubgiminski/value-object

Library of abstract classes intended to be used as bases for value objects.

  • Sunday, January 1, 2017
  • by jakubgiminski
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Value Object

This library is useful for building value objects in php. It is a collection of abstract classes (each for every scalar type), that contain common validation mechanisms, so you don't have to write them., (*1)

So far, we have StringValue and IntegerValue which already satisfy most of the needs. More scalar representations may be implemented in the future (feel free to contribute)., (*2)

Look here to find some unit tested examples., (*3)

Required PHP version: 7.0.0 or higher, (*4)

Installation

composer require jakubgiminski/value-object

Overview

Every ValueObject has a getValue() method., (*5)

ValueObject\StringValue

Validation rules (optional):, (*6)

/** @var int */
protected $minLength;

/** @var int */
protected $maxLength;

/** @var array */
protected $validValues = [];

Comparison methods:, (*7)

public function isEqual(StringValueInterface $stringValue): bool;
public function isShorterThan(StringValueInterface $stringValue): bool;
public function isLongerThan(StringValueInterface $stringValue): bool;

Examples of usage: - Season - Password, (*8)

ValueObject\IntegerValue

Validation rules (optional):, (*9)

/** @var array */
protected $validRange = [];

/** @var array */
protected $validValues = [];

/** @var array */
protected $invalidValues = [];

Comparison methods:, (*10)

public function isEqual(IntegerValueInterface $integerValue): bool;
public function isLessThan(IntegerValueInterface $integerValue): bool;
public function isGreaterThan(IntegerValueInterface $integerValue): bool;

Examples of usage: - Age - TheatreSeat, (*11)

The Versions

01/01 2017

dev-master

9999999-dev

Library of abstract classes intended to be used as bases for value objects.

  Sources   Download

The Development Requires

by Jakub Giminski