PHPackages                             compono-kit/types - 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. compono-kit/types

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

compono-kit/types
=================

Basic type classes wrapping scalar values to create types in applications. Implementations of compono-kit/types-interfaces

1.0.0(today)001proprietaryPHPPHP &gt;=8.0

Since Jun 20Pushed todayCompare

[ Source](https://github.com/compono-kit/types)[ Packagist](https://packagist.org/packages/compono-kit/types)[ RSS](/packages/compono-kit-types/feed)WikiDiscussions feature/8.0 Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

ComponoKit / Types
==================

[](#componokit--types)

**Strongly typed value objects for PHP 8+**

This package provides a lightweight foundation for building *domain-driven*, *immutable*, and *type-safe* value objects in PHP implementing `compono-kit/types-interfaces`. Each type implements its own interfaces and can be used directly via traits or abstract classes. It is designed for type safety, validation, and consistent methods for comparison, conversion, and manipulation.

100% code coverage without senseless LLM generated tests!

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

[](#requirements)

- PHP 8+
- compono-kit/types-interfaces

---

🚀 Installation
--------------

[](#-installation)

```
composer require compono-kit/types
```

---

Type Overview
-------------

[](#type-overview)

TypeInterfaceDescriptionBooleanType`RepresentsBoolean`Represents a boolean value with conversion and comparison methodsIntegerType`RepresentsInteger`Represents an integer with mathematical and comparison operationsFloatType`RepresentsFloat`Represents a float with mathematical and comparison operationsStringType`RepresentsString`Represents a string with extensive methods for manipulation, comparison, and regexDateType`RepresentsDate`Represents a date/time with comparison, addition/subtraction, and formattingUuid4`RepresentsString`Represents a Uuid v4 valueUuid7`RepresentsString`Represents a Uuid v7 valueAll types implement the base interface `RepresentsType`, which includes methods such as `equals()` and `toNativeType()`.

---

Architecture
------------

[](#architecture)

Each type can be used in three ways:

1. **Trait** – Implements all interface methods.
    Advantage: You can use traits in your own classes without inheriting the abstract class.

    ```
    class MyString {
        use RepresentingString;
    }

    $str = new MyString("Hello World");
    echo $str->toUpperCase(); // "HELLO WORLD"
    ```
2. **Abstract Class** – Uses the trait and adds an abstract `isValid()` method for validation.
    Advantage: Easily extendable for specific type rules.

    ```
    abstract class AbstractEmail extends AbstractString {
        public static function isValid(string $value): bool {
            return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
        }
    }
    ```
3. **Default Implementation** – Standard implementation without special validation.
    Advantage: Quick usage for generic types.

    ```
    $string = new StringType("Hello World");
    echo $string->toUpperCase(); // "HELLO WORLD"
    ```

---

Usage Examples
--------------

[](#usage-examples)

### String

[](#string)

```
use ComponoKit\Types\StringType;

$string = new StringType("Hello World");

echo $string->toLowerCase();   // "hello world"
echo $string->capitalizeFirst(); // "Hello World"
echo $string->contains("World");  // true
```

### Integer

[](#integer)

```
use ComponoKit\Types\IntegerType;

$int = new IntegerType(42);

$int2 = $int->add(8); // 50
var_dump($int2->isPositive()); // true
```

### Float

[](#float)

```
use ComponoKit\Types\FloatType;

$float = new FloatType(3.14);

$float2 = $float->multiply(2); // 6.28
var_dump($float2->isGreaterThan(5.0)); // true
```

### Boolean

[](#boolean)

```
use ComponoKit\Types\BooleanType;

$bool = new BooleanType(true);

var_dump($bool->isTrue()); // true
var_dump($bool->toInteger()); // 1
```

### Date

[](#date)

```
use ComponoKit\Types\DateType;

$date = new DateType(new \DateTimeImmutable("2025-11-22"));

$tomorrow = $date->add(new \DateInterval('P1D'));
var_dump($tomorrow->isGreaterThan($date)); // true

$diff = $date->diff($tomorrow, false);
echo $diff->format('%d days'); // "1 days"
```

### UUID4

[](#uuid4)

```
use ComponoKit\Types\Uuid4;

$uuid = Uuid4::generate();
echo $uuid->toString(); // e.g., "550e8400-e29b-41d4-a716-446655440000"
```

---

Exceptions
----------

[](#exceptions)

All types use their own exceptions derived from `RepresentsTypeException`.

---

Summary
-------

[](#summary)

- **Traits**: Full interface implementation, usable without abstract classes.
- **Abstract Classes**: Traits + `isValid()` method for custom validation logic.
- **Default Types**: Quick start without custom validation.
- **UUID4**: Special string type with generated UUID.
- **Benefits**: Type safety, consistent methods, easy extensibility and validation.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b4875ebadf24ddeae09bd59c44c9a86a61c3d3892fe1d4a264ad167b6d230cc?d=identicon)[Hansel23](/maintainers/Hansel23)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/compono-kit-types/health.svg)

```
[![Health](https://phpackages.com/badges/compono-kit-types/health.svg)](https://phpackages.com/packages/compono-kit-types)
```

###  Alternatives

[elhebert/laravel-sri

Subresource Integrity hash generator for laravel

39241.9k](/packages/elhebert-laravel-sri)[mtdowling/burgomaster

Packages up PHP packages into zips and phars

2780.9k12](/packages/mtdowling-burgomaster)[francescomalatesta/laravel-circuit-breaker

A circuit breaker pattern implementation for the Laravel framework

2919.2k2](/packages/francescomalatesta-laravel-circuit-breaker)

PHPackages © 2026

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