PHPackages                             alcidesrc/severe - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alcidesrc/severe

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alcidesrc/severe
================

Even more severe with strict types in PHP

1.0.3(1y ago)14MITPHPPHP ^8.3CI passing

Since May 17Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/AlcidesRC/severe)[ Packagist](https://packagist.org/packages/alcidesrc/severe)[ RSS](/packages/alcidesrc-severe/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (9)Versions (5)Used By (0)

[![Continuous Integration](https://github.com/fonil/severe/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fonil/severe/actions/workflows/ci.yml)

Severe
======

[](#severe)

> Avoid data type conflicts in PHP being more severe

\[TOC\]

Summary
-------

[](#summary)

This repository offers a collection of PHP classes that enforce strict data types, ensuring more reliable and maintainable code. By leveraging these classes, developers can reduce bugs, improve code readability, and enhance overall software quality.

Requirements
------------

[](#requirements)

This library requires PHP^8.3

Installation
------------

[](#installation)

Install `Severe` using Composer:

```
composer require fonil/severe
```

Supported Data Types
--------------------

[](#supported-data-types)

`Severe` supports the following data types:

TypeCategoryVersionArrayGeneric1.0BooleanGeneric1.0ClosureGeneric1.0FloatGeneric1.0IntegerGeneric1.0NullGeneric1.0ObjectGeneric1.0StringGeneric1.0MoneyFinances1.0DomainInternetTODOEmailInternetTODODocumentFile SystemTODOImageFile SystemTODO### Generic Data Types

[](#generic-data-types)

#### Usage

[](#usage)

##### Setters

[](#setters)

`Severe` provides a static public method `set()` that validates the input and creates a data type instance when succeed.

> In case of invalid argument type a `TypeError` is thrown

```
use Severe\TypeString;
use Severe\TypeBoolean;
use Severe\TypeNull;

$string = TypeString::set($var);
$bool = TypeBoolean::set($flag);
$null = TypeNull::set($optional);
...
```

##### Getters

[](#getters)

All `Severe` data type instances are `_invokable` classes so you can get the values as follow:

```
$value = $string();
$flag = $bool();
$optional = $null();
...
```

### Ennumeration Classes

[](#ennumeration-classes)

#### Currency

[](#currency)

To handle valid currencies a backed enumeration class is provided called `Currency` which allows you to get the `name`, `symbol`, `code` and `decimals` for allowed currencies.

##### Usage

[](#usage-1)

###### Examples

[](#examples)

```
use Severe\Enums\Currency;

$currency = Currency::EUR;
echo $currency->value;       // EUR
echo $currency->code();      // 978
echo $currency->name();      // Euro
echo $currency->decimals();  // 2

$currency = Currency::UYI;
echo $currency->value;       // UYI
echo $currency->code();      // 940
echo $currency->name();      // Uruguay Peso en Unidades Indexadas (URUIURUI)
echo $currency->decimals();  // 0

// Dynamic instantiation
$currency = Currency::from('TRY');
echo $currency->value;       // TRY
echo $currency->code();      // 949
echo $currency->name();      // Turkish Lira
echo $currency->decimals();  // 2
```

### Additional Data Types

[](#additional-data-types)

#### Money

[](#money)

Additionally, `Severe` provides a custom data type to handle money entities. Those entities has two components:

- Amount: a float number indicating the amount of money
- Currency: a currency entity

##### Usage

[](#usage-2)

###### Setters

[](#setters-1)

All of those ways are supported and equivalents:

```
use Severe\Enums\Currency;
use Severe\TypeFloat;
use Severe\TypeMoney;

$money = TypeMoney::set(123.456, 'eur');
$money = TypeMoney::set(123.456, Currency::EUR);
$money = TypeMoney::set(TypeFloat::set(123.456), 'EUR');
$money = TypeMoney::set(TypeFloat::set(123.456), Currency::EUR);
```

###### Getters

[](#getters-1)

```
[$amount, $currency] = $money();

// $amount is an instance of TypeFloat
// $currency is an instance of Currency
```

###### Examples

[](#examples-1)

```
$money = TypeMoney::set(123.456789, 'EUR');
[$amount, $currency] = $money();
echo $amount();                  // 123.46
echo $currency->value;           // EUR

$money = TypeMoney::set(123.456789, 'CLF');
echo $money()[0]->__invoke();    // 123.4568
echo $money()[1]->decimals();    // 4
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review our security policy on how to report security vulnerabilities:

**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY**

### Supported Versions

[](#supported-versions)

Only the latest major version receives security fixes.

### Reporting a Vulnerability

[](#reporting-a-vulnerability)

If you discover a security vulnerability within this project, please [open an issue here](https://github.com/fonil/severe/issues). All security vulnerabilities will be promptly addressed.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](./LICENSE) file for more information.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance55

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Total

4

Last Release

676d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac46b16e9e44092d94c7346f48abb796b38f2ca9553bd264cea563fc4854644b?d=identicon)[AlcidesRC](/maintainers/AlcidesRC)

---

Top Contributors

[![AlcidesRC](https://avatars.githubusercontent.com/u/1401102?v=4)](https://github.com/AlcidesRC "AlcidesRC (10 commits)")

---

Tags

data-typesphp8qaphpclean codeBest-Practicesstrict types

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alcidesrc-severe/health.svg)

```
[![Health](https://phpackages.com/badges/alcidesrc-severe/health.svg)](https://phpackages.com/packages/alcidesrc-severe)
```

###  Alternatives

[firefly-iii/data-importer

Firefly III Data Import Tool.

8015.8k](/packages/firefly-iii-data-importer)[strictus/strictus

Strict Typing for local variables in PHP

1627.4k](/packages/strictus-strictus)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21623.4k](/packages/imanghafoori-laravel-anypass)[hi-folks/data-block

Data class for managing nested arrays and JSON data.

1462.9k](/packages/hi-folks-data-block)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
