PHPackages                             aviator/length-aware-string - 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. aviator/length-aware-string

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

aviator/length-aware-string
===========================

A string class with length handling strategies

0.1.2(8y ago)11.6k↑500%MITPHPPHP &gt;=7.0.0

Since Dec 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/danielsdeboer/length-aware-string)[ Packagist](https://packagist.org/packages/aviator/length-aware-string)[ Docs](https://github.com/danielsdeboer/length-aware-string)[ RSS](/packages/aviator-length-aware-string/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (6)Used By (0)

[![Build Status](https://camo.githubusercontent.com/e8c6f5aee86412e8f445331bec63dff600198c043a792735ae18b41c017aabdb/68747470733a2f2f7472617669732d63692e6f72672f64616e69656c736465626f65722f6c656e6774682d61776172652d737472696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/danielsdeboer/length-aware-string)[![Latest Stable Version](https://camo.githubusercontent.com/734f50cdab95f4c6c4642095a1b8b0da6cba6dc607f14b62c829a5370f47e07c/68747470733a2f2f706f7365722e707567782e6f72672f61766961746f722f6c656e6774682d61776172652d737472696e672f762f737461626c65)](https://packagist.org/packages/aviator/length-aware-string)[![License](https://camo.githubusercontent.com/7de7a299227558282c2be2566799045460b15b5dd792477330a82498183fa564/68747470733a2f2f706f7365722e707567782e6f72672f61766961746f722f6c656e6774682d61776172652d737472696e672f6c6963656e7365)](https://packagist.org/packages/aviator/length-aware-string)

Overview
--------

[](#overview)

LengthAwareString is a string wrapper concerned with string length. By default it truncates strings that fail validation, but can be (optionally) given a strategy object to provide different functionality.

### Installation

[](#installation)

Via Composer:

```
composer require aviator/length-aware-string

```

### Testing

[](#testing)

Via Composer:

```
composer test

```

### Usage

[](#usage)

`LengthAwareString` requires at least two parameters, a string and an integer length:

```
$las = LengthAwareString::make('string', 5);
```

The string length is validated and handled on instantiation. If no validation strategy is provided the class will use `Truncates`, which does what it says on the tin.

You can provide an alternative strategy implementing the `StringLengthValidator` contract:

```
$las = LengthAwareString::make('string', 5, new YourStrategy);
```

This package also provides a `Throws` strategy which throws an exception if the string is too long.

To get the result you can call `get()`:

```
$las->get();

// 'string'
```

The class implements `__toString()` so you can treat it like a string:

```
echo $las;

// 'string'
```

The class implements `Countable` so you can `count()` it:

```
echo count($las);

// 6
```

Other
-----

[](#other)

### License

[](#license)

This package is licensed with the [MIT License (MIT)](LICENSE).

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

3

Last Release

3017d ago

### Community

Maintainers

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

---

Top Contributors

[![danielsdeboer](https://avatars.githubusercontent.com/u/13170241?v=4)](https://github.com/danielsdeboer "danielsdeboer (6 commits)")

---

Tags

length-handlingphpphp7stringsphpstringsPHP7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aviator-length-aware-string/health.svg)

```
[![Health](https://phpackages.com/badges/aviator-length-aware-string/health.svg)](https://phpackages.com/packages/aviator-length-aware-string)
```

###  Alternatives

[glowy/strings

Strings Component provide a fluent, object-oriented interface for working with multibyte string, allowing you to chain multiple string operations together using a more readable syntax compared to traditional PHP strings functions.

183.3k2](/packages/glowy-strings)

PHPackages © 2026

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