tessera-php / tessera-type-int
Tessera type: Integer
dev-main
2026-02-23 09:58 UTC
Requires
- php: 8.1 - 8.5
- tessera-php/tessera-core: dev-main
Requires (Dev)
- phpunit/phpunit: ^10.0
Provides
- tessera-contract-type/int: 1.0.0
This package is auto-updated.
Last update: 2026-04-25 18:11:39 UTC
README
Целочисленный тип для Tessera.
Установка
composer require tessera-php/tessera-type-int
Использование
use Tessera\Type\Int\IntType; use Tessera\Type\Int\IntData; $type = new IntType(); // Валидация $type->validate(42); // true $type->validate('42'); // true $type->validate(42.0); // true (float без дробной части) $type->validate(3.14); // false $type->validate('abc'); // false // Нормализация $data = $type->normalize('42'); echo $data->value; // 42 (int) // DTO $data = new IntData(123); echo $data->value; // 123
Принимаемые форматы
int— нативное целое числоbool— булево значение (приводится к 0 или 1)string— числовая строка ('42', '-10', '+5')float— только без дробной части (42.0, -10.0)
Контракт
provide: tessera-contract-type/int
Лицензия
MIT