insidesuki / valueobject
Common value objects
Installs: 384
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/insidesuki/valueobject
Requires
- php: >=8.1
 - phpunit/phpunit: >=9.5
 
Requires (Dev)
- symfony/var-dumper: ^5.4
 
- dev-main
 - 3.5.17
 - 3.5.16
 - 3.5.14
 - 3.5.12
 - 3.5.11
 - 3.5.10
 - 3.5.9
 - 3.5.8
 - 3.5.7
 - 3.5.6
 - 3.5.5
 - 3.5.4
 - 3.5.3
 - 3.5.2
 - 3.5.1
 - 3.5
 - 3.4.1
 - 3.4
 - 3.3.6
 - 3.3.5
 - 3.3.4
 - 3.3.3
 - 3.3.2
 - 3.3.1
 - 3.2.3
 - 3.2.2
 - 3.2.1
 - 3.2
 - 3.1.5
 - 3.1.4
 - 3.1.3
 - 3.1.2
 - 3.1.1
 - 3.0.0
 - 2.9.2
 - 2.9.1
 - 2.9
 - 2.8
 - 2.7
 - 2.6
 - 2.5
 - 2.4
 - 2.3
 - 2.2
 - 2.1
 - 2.0
 - 1.17
 - 1.16
 - 1.15
 - 1.14.9
 - 1.14.8
 - 1.14.7
 - 1.14.6
 - 1.14.5
 - 1.14.4
 - 1.14.3
 - 1.14.2
 - 1.14.1
 - 1.14
 - 1.12
 - 1.11
 - 1.10.3
 - 1.10.2
 - 1.10.1
 - 1.10.0
 - 1.9.1
 - 1.9
 - 1.8
 - 1.7.1
 - 1.7
 - 1.6.1
 - 1.6.0
 - 1.5.1
 - 1.5.0
 - 1.4.2
 - 1.4.1
 - 1.4
 - 1.3.5
 - 1.3.4
 - 1.3.3
 - 1.3.2
 - 1.3.1
 - 1.3
 - 1.2.19
 - 1.2.18
 - 1.2.17
 - 1.2.16
 - 1.2.15
 - 1.2.14
 - 1.2.13
 - 1.2.12
 - 1.2.11
 - 1.2.10
 - 1.2.9
 - 1.2.8
 - 1.2.7
 - 1.2.6
 - 1.2.5
 - 1.2.4
 - 1.2.3
 - 1.2.2
 - 1.2.1
 - 1.2
 - 1.1
 - 1.0.3
 - 1.0.2
 - 1.0.1
 - 1.0.0
 - 0.0.17
 - 0.0.15
 - 0.0.14
 - 0.0.13
 - 0.0.12
 - 0.0.11
 - 0.0.10
 - 0.0.9
 - 0.0.8
 - 0.0.7
 - 0.0.6
 - 0.0.5
 - 0.0.4
 - 0.0.3
 - 0.0.2
 - 0.0.1
 
This package is auto-updated.
Last update: 2025-10-06 15:54:49 UTC
README
Common ValueObjects. Complete doc: https://gitlab.com/insidesuki/valueobject
1- DateValue
Simple ValueObject to manage DateTime types.
- To create a new DateValue :
$startData = DateValue::create('31-10-2010'); 
- Exception on invalid date
> InvalidDateException
- Get Age
$date = DateValue::create('31-10-2010'); echo $date->age();
**2- DocumentNumber**
--
Spanish NIF/CIF/NIF. Support for Passport type(no validation available)
- Supported types:
enum DocumentType: string {
case nif = '10';
case passport = '20';
case nie = '60';
case cif = '90';
}
- To create a new DocumentNumber by DocumentType
```
// nif
$nif = DocumentNumber::createByType('90','Z3740746P');
On invalid number throws InvalidDocumentNumberException
On invalid documentType throws InvalidDocumentTypeException
- To create a new DocumentNumber without specify type
 
// number, documentType detected on execution time
$number = DocumentNumber::create('Z3740746P');
// to avoid validation, passport type returned
$numberWithoutValidatin = DocumentNumber::create('posduhsui',false);
- To change DocumentNumber with specify type
 
$nif->change('60','newNumber');
3- FullName
Name, lastname1,lastname2 Lastname2 is optional
// lastname2 is optional
$name = '  james  ';
$lastname = '    bond  ';
$lastname1 = ' ';
$fullName = FullNameValue::create($name,$lastname,$lastname1);
4- Gender
Generic Gender, admits empty string
- GenderTypes
 
enum GenderType:string
{
	case Masculino = '1';
	case Femenino = '2';
	case Undefined = '';
}
- To create
// Female Gender::create('2'); // Male Gender::create('1'); // Undefined Gender::create(''); 
- Exceptions
> InvalidGenderTypeException
**5- EmailValue**
--
Email value object, admits empty string 
- To create
// valid $email = EmailValue::create($emailString); // empty $email = EmailValue::createAllowEmpty(''');
 
- Exceptions
> InvalidEmailException
**6- PhoneNumberValue**
--
PhoneNumber value object, admits empty string
- To create
// valid $phone = PhoneValue::createPhone('987154362'); // empty $phoneEmpty = PhoneValue::createPhoneAllowEmpty('');
 
// movil $movil = PhoneValue::createMovilPhone('714652391'); // empty $movil = PhoneValue::createMovilPhoneAllowEmpty('714652391');
- Exceptions
> InvalidPhoneNumberException
> EmptyPhoneNumberException
**7- NivelEstudioValue**
--
FUNDAE nivel estudios
**8- CategoriaProfesionalValue**
--
FUNDAE categoria profesional.
**9- GrupoCotizacionValue**
--
FUNDAE grupo cotizacion
**10- CuentaCotizacionValue**
--
FUNDAE cuenta cotizacion
**11- TerrorismoValue**
--
FUNDAE afectados terrorismo.
**12- ViolenciaValue**
--
FUNDAE afectados violencia de genero
**14- DiscapacidadValue**
--
FUNDAE afectados discapacidad.
**15- Amount**
--