PHPackages                             lia-tec/caster - 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. lia-tec/caster

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

lia-tec/caster
==============

Cast types

0.2.0(3y ago)0231MITPHPPHP &gt;=7.2

Since Apr 11Pushed 3y ago1 watchersCompare

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

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

Caster
======

[](#caster)

Castea un valor a diferentes tipos

Usage
-----

[](#usage)

```
    Cast::as($value, 'type')
```

Type chain

```
     Cast::as('   -159.056     ', 'trim|abs|currency')
     //159.06
```

Cast
----

[](#cast)

```
Cast::as('   -159.056     ', 'trim|abs|currency') //159.06
Cast::as('     999   ', 'spaces') //999
Cast::as('     999   ', 'trim') //999
Cast::as(['1'], 'boolean') //true
Cast::as('true', 'boolean') //true
Cast::as(' true ', 'boolean') //true
Cast::as(['3',4], 'boolean') //true
Cast::as('false', 'boolean') //false
Cast::as('other', 'boolean') //true
Cast::as('', 'boolean') //false
Cast::as('0', 'boolean') //false
Cast::as(0, 'boolean') //false
Cast::as([], 'boolean') //false
Cast::as('18-ene-2022', 'date') //Carbon\Carbon
Cast::as('15-11-1985', 'date') //Carbon\Carbon
Cast::as('2022-02-25', 'date') //Carbon\Carbon
Cast::as('2022-02', 'date') //Carbon\Carbon (year and month)
Cast::as('2022-feb', 'date') //Carbon\Carbon (year and month)
Cast::as('jun-1985', 'date') //Carbon\Carbon (year and month)
Cast::as('123.126666', 'integer') //123
Cast::as('123.126666', 'int') //123
Cast::as('123.126666', 'float') //123.126666
Cast::as('123.126666', 'double') //123.126666
Cast::as('123.126666', 'currency') //123.13
Cast::as('1578.56666', 'currency') //1578.57
Cast::as('1578.544466', 'currency') //1578.54
```

Manipulations
-------------

[](#manipulations)

```
Cast::as('   123456789     ', 'trim|truncate:3') //123
Cast::as('123.126666', 'roundup:3') //123.127
Cast::as('123.126666', 'round:3') //123.127
Cast::as('1221.129316666', 'round:2') //1221.13
Cast::as('123.9999', 'floor') //123
Cast::as('123.126666', 'ceil') //124

// spread:max-words:max-items:key1,key2,key(max-items)
Cast::as('123123123', 'spread:3') //['123','123','123']
Cast::as('123123123', 'spread:3,2') //['123','123']
Cast::as('123123123', 'spread:3,2,one,two') //['one'=>'123','two'=>'123']

// spreadword:max-words:max-items:key1,key2,key(max-items)
$str = 'Lorem ipsum dolor sit amet consectetur, adipisicing elit.';
Cast::as($str, 'spreadword:4:2') //['Lorem', 'ipsum']
Cast::as($str, 'spreadword:4,2,line1,line2') //['line1' => 'Lorem', 'line2' => 'ipsum']
Cast::as($str, 'spreadword:spreadword:15') //['Lorem ipsum', 'dolor sit amet', 'consectetur,', 'adipisicing', 'elit.']
```

Licence
-------

[](#licence)

This package is open-sourced software licensed under the [MIT](https://opensource.org/licenses/MIT) license.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

1397d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77f97d9ced0816f55357cf6c52d953ad7234d9eaa2e971f4e5340500df8803db?d=identicon)[lia\_tec](/maintainers/lia_tec)

---

Top Contributors

[![cmpere](https://avatars.githubusercontent.com/u/4393094?v=4)](https://github.com/cmpere "cmpere (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lia-tec-caster/health.svg)

```
[![Health](https://phpackages.com/badges/lia-tec-caster/health.svg)](https://phpackages.com/packages/lia-tec-caster)
```

###  Alternatives

[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[intervention/zodiac

Zodiac Sign Calculator

58191.7k](/packages/intervention-zodiac)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[solspace/craft-calendar

The most powerful event management and calendaring plugin!

1830.8k1](/packages/solspace-craft-calendar)

PHPackages © 2026

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