PHPackages                             anothanj/casterly - 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. anothanj/casterly

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

anothanj/casterly
=================

A PHP library for type casting.

0135↓33.3%PHPCI passing

Since Jan 19Pushed 3mo agoCompare

[ Source](https://github.com/anothanj/casterly)[ Packagist](https://packagist.org/packages/anothanj/casterly)[ RSS](/packages/anothanj-casterly/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Casterly
========

[](#casterly)

A PHP library for safe type casting that is compatible with PHPStan static analysis.

Casterly provides type casting utilities that help you cast mixed values to scalar types while maintaining type safety and PHPStan compatibility. This is particularly useful when working with data from external sources (APIs, form inputs, configuration files) where you know the expected type but need to satisfy static analysis requirements.

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

[](#installation)

Install via Composer:

```
composer require anothanj/casterly
```

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

[](#requirements)

- PHP 8.4 or higher

Usage
-----

[](#usage)

### Quick Start with the Cast Utility Class

[](#quick-start-with-the-cast-utility-class)

The simplest way to use Casterly is through the static `Cast` utility class:

```
