bermudaphp / checktype
Requires
- php: ^8.0
This package is auto-updated.
Last update: 2025-04-21 15:12:15 UTC
README
A lightweight PHP library for determining and enforcing variable types.
Легковесная PHP-библиотека для определения и обеспечения типов переменных.
Features / Возможности
-
Type Detection / Определение Типа
Provides thegetType()
method to determine the type of any given variable, including returning class names when desired. -
Type Enforcement / Обеспечение Типов
Enforces allowed types using theenforce()
method, throwing detailed error messages with caller information when expectations are not met. -
Class & Interface Checks / Проверка Классов и Интерфейсов
Validates class and interface names withisClass()
andisInterface()
methods, ensuring accurate type checks. -
Flexible Configuration / Гибкая Настройка
Uses bitmask flags such asFLAG_OBJECT_AS_CLASS
andFLAG_CALLABLE_AS_OBJECT
to customize behavior.
Installation / Установка
This library requires PHP 8.0 or higher.
Эта библиотека требует PHP 8.0 или выше.
Install via Composer:
Установите через Composer:
composer require bermudaphp/checktype
Usage / Использование
use Bermuda\CheckType\Type; $value = 42; // Determine the type of the variable echo Type::getType($value); // Outputs: int // Enforce allowed types Type::enforce(static fn() => 42, [Type::TYPE_CALLABLE, \Closure::class]);