PHPackages                             star/php-type - 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. star/php-type

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

star/php-type
=============

Package to wrap basic php types behind a common interface

2.0.0(2y ago)01.2k1[2 issues](https://github.com/yvoyer/php-type/issues)[1 PRs](https://github.com/yvoyer/php-type/pulls)1MITPHPPHP ^7.0|^8.0

Since Apr 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yvoyer/php-type)[ Packagist](https://packagist.org/packages/star/php-type)[ RSS](/packages/star-php-type/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (3)Used By (1)

PHP type value wrapper
======================

[](#php-type-value-wrapper)

[![Build Status](https://github.com/yvoyer/php-type/actions/workflows/Tests.yml/badge.svg)](https://github.com/yvoyer/php-type/actions/workflows/Tests.yml/badge.svg)

Basic OOP classes to wrap php basic types conversion behind a common interface.

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

[](#installation)

`composer require star/php-type`

Casting value
-------------

[](#casting-value)

You can use [ValueGuesser](src/ValueGuesser.php) to convert a mixed value to the object type.

```
use Star\Component\Type\ValueGuesser;

$int = ValueGuesser::fromMixed(12);
$int->isEmpty(); // false
$int->toBool(); // true
$int->toDate(); // throws Exception
$int->toFloat(); // 12.0
$int->toInteger(); // 12
$int->toString(); // "12"
```

Hooking into the type
---------------------

[](#hooking-into-the-type)

When you don't know which type will be returned, the `ValueVisitor` allows you to define operations per type (like a switch case).

```
use Star\Component\Type\BooleanValue;
use Star\Component\Type\ValueVisitor;

$true = BooleanValue::asTrue();
$true->acceptValueVisitor(
    new class implements ValueVisitor {
        ...
        public function visitFloatValue(float $value): void {
            // do your custom operation when the value is float.
        }
        ...
    }
);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

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 ~635 days

Total

2

Last Release

916d ago

Major Versions

1.0.0 → 2.0.02023-12-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/36116f724f1bd3ed808e54e2b2de6c17209c5c2c1954685fba18958ec8d055ee?d=identicon)[yvoyer](/maintainers/yvoyer)

---

Top Contributors

[![yvoyer](https://avatars.githubusercontent.com/u/1745744?v=4)](https://github.com/yvoyer "yvoyer (7 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/star-php-type/health.svg)

```
[![Health](https://phpackages.com/badges/star-php-type/health.svg)](https://phpackages.com/packages/star-php-type)
```

###  Alternatives

[promptphp/deck

Deck is a Laravel and PHP package for versioned, file-based AI prompt management with variable interpolation, performance tracking, A/B testing, and optional Laravel AI SDK integration.

1003.1k](/packages/promptphp-deck)[skoyah/unit-converter

A simple tool for converting units of measurement.

132.5k](/packages/skoyah-unit-converter)[psmb/createnodebutton

Create the nodes in Neos even without the tree...

151.2k](/packages/psmb-createnodebutton)

PHPackages © 2026

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