2017 © Pedro Peláez
 

library length-aware-string

A string class with length handling strategies

image

aviator/length-aware-string

A string class with length handling strategies

  • Tuesday, December 19, 2017
  • by danielsdeboer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version License, (*1)

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., (*2)

Installation

Via Composer:, (*3)

composer require aviator/length-aware-string

Testing

Via Composer:, (*4)

composer test

Usage

LengthAwareString requires at least two parameters, a string and an integer length:, (*5)

$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., (*6)

You can provide an alternative strategy implementing the StringLengthValidator contract:, (*7)

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

This package also provides a Throws strategy which throws an exception if the string is too long., (*8)

To get the result you can call get():, (*9)

$las->get();

// 'string'

The class implements __toString() so you can treat it like a string:, (*10)

echo $las;

// 'string'

The class implements Countable so you can count() it:, (*11)

echo count($las);

// 6

Other

License

This package is licensed with the MIT License (MIT)., (*12)

The Versions

19/12 2017

dev-master

9999999-dev https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7

19/12 2017

0.1.2

0.1.2.0 https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7

19/12 2017

dev-implement-countable

dev-implement-countable https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7

15/12 2017

0.1.1

0.1.1.0 https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7

15/12 2017

dev-add-pads

dev-add-pads https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7

14/12 2017

0.1.0

0.1.0.0 https://github.com/danielsdeboer/length-aware-string

A string class with length handling strategies

  Sources   Download

MIT

The Requires

 

The Development Requires

php strings php7