2017 © Pedro Peláez
 

library formatter

Rule-based string format.

image

urmaul/formatter

Rule-based string format.

  • Monday, July 4, 2016
  • by urmaul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 141 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

Formatter

Rule-based string formatters. Made for polishing parsed data., (*1)

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Installing

composer require urmaul/formatter dev-master, (*3)

Using

$values = ['foo' => '  bar  ', 'spam' => 'ham | foo | bar'];

$formatter = new Formatter([
    ['foo', 'trim'],
    ['spam', 'cut', ' | '],
]);
$values = $formatter->format($values);

// $values = ['foo' => 'bar', 'spam' => 'ham'];

Actions

  • cut(delimiter) - returns string part between beginning and delimiter.
  • rcut(delimiter) - returns string part between delimiter and ending.
  • remove(substring) - removes substring. See str_replace.
  • replace(substring, replacement) - replaces substring with replacement. See str_replace.
  • removeMatch(pattern) - removes pattern. See preg_replace.
  • replaceMatch(pattern, replacement) - replaces pattern with replacement. See preg_replace.
  • map(array map) - replaces string with value from map.
  • between(leftBorder, rightBorder) - returns string part between first occurence of leftBorder and rightBorder.
  • trim([character_mask = " \t\n\r0\x0B"]) - strips whitespace (or other characters) from the beginning and end of a string.
  • callback(callable) - processes string with callback.
  • grep(substring) - returns lines containing substring.
  • stripTags([allowable_tags]) - strips HTML and PHP tags from a string. See strip_tags.
  • iconv([encoding_from, encoding_to]) - converts character encoding. Defaults are "UTF-8" - "UTF-8//IGNORE" which remove invalid characters from utf-8 string.
  • stripWhitespaces(string) - returns string without unprintable characters.

The Versions

04/07 2016

dev-master

9999999-dev https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

23/10 2015

v1.5.0

1.5.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

25/02 2015

v1.4.1

1.4.1.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

04/02 2015

v1.4.0

1.4.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

09/09 2014

v1.3.0

1.3.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

25/08 2014

v1.2.0

1.2.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

24/08 2014

v1.1.0

1.1.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format

07/08 2014

v1.0.0

1.0.0.0 https://github.com/urmaul/formatter

Rule-based string format.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

formatter string format