PHPackages                             juanchosl/datamanipulation - 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. juanchosl/datamanipulation

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

juanchosl/datamanipulation
==========================

Little methods collection in order to manipulate variables contents

1.0.2(3mo ago)11065MITPHPPHP ^8.0

Since Jan 7Pushed 3mo agoCompare

[ Source](https://github.com/JuanchoSL/DataManipulation)[ Packagist](https://packagist.org/packages/juanchosl/datamanipulation)[ Docs](https://github.com/JuanchoSL/DataManipulation)[ RSS](/packages/juanchosl-datamanipulation/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (5)

DataManipulation
================

[](#datamanipulation)

Description
-----------

[](#description)

Little methods collection in order to manipulate variables contents. Group of some features in order to clean, modify, convert, apply math operations and some other actions

Install
-------

[](#install)

```
composer require juanchosl/datamanipulation
```

Manipulators
------------

[](#manipulators)

### Strings

[](#strings)

Perform actions over strings, using multibyte functions where are available, and returns a new StringManipulator object in order to mantain inmutability over previous entities

ManipulationMultiByteDescriptionsubstringXExtract a part of a string, starting from indicated offset and with the desired lenghtsubstringBeforeCharXExtract a part of a string, ending at indicated charsubstringAfterCharXExtract a part of a string, starting from indicated charrepeatRepeat the string n timesformatApply format, with indicated values, to the stringreplaceSearch and replace a substring, can be case sensitive or notreverseApply a reverse to the stringtoUpperFirstXTo upper the first char of the stringtoLowerFirstXTo lower the first char of the stringtoUpperWordsTo upper the first char of every word into the string, can be indicated the char separator, not only spacestoUpperXTo upper all the stringtoLowerXTo lower all the stringpaddingXFill the string to the desired lenght with the value, at the left, rigth or bothpreppendXConcat a new value at the start of the string, can be indicated an union char, a space is used if notconcatenationXConcat a new value at the end of the string, can be indicated an union char, a space is used if notchunkXConvert to a multiline string with a fix lenghtwordWrapConvert to a multiline string with a fix lenght, but safely for word, ensuring do not cut, applying from the previous spacetrimXClean a string, removing spaces or control chars at the start or the end of the stringltrimXClean a string, removing spaces or control chars at the start of the stringrtrimXClean a string, removing spaces or control chars at the end of the stringeolXConvert breaklines chars (\\r,\\n,\\r\\n) to the desired new char, in order to ensure the use of PHP\_EOL constant for unknow originsshuffleApply a random shuffleexplodeExplode a string and returns a StringManipulators collection for every partsrotate13Apply a rot13 transformationmd5Calculate the md5quotedPrintableEncodeConvert form 8bits string to QP string, following the rules from RFC2045quotedPrintableDecodeConvert to 8bits string from QP string, following the rules from RFC2045uuEncodeEncode the string using the uuencode algorithmuuDecodeDecode a uuencoded stringurlEncodeEncode the string using the rawurlencode algorithm, following the rules from RFC3986urlDecodeDecode a rawurlencoded string, following the rules from RFC3986base64EncodeEncode to Base 64base64DecodeDecode from Base 64base64UrlEncodeEncode to Base 64 URL safebase64UrlDecodeDecode from Base 64 URL safebinToHexConvert the binary string to hexadecimal equivalenthexToBinConvert the hexadecimal string to binary datahashHmacCalculate the hash, using an algorithm and key, of a string### Numbers

[](#numbers)

OperationDescriptionabsoluteThe positive value, ignoring the original, allways to positivenegationthe inversed, if is a positive, converts to negativesumsum a quantity to the internal object valuesubsubstraction a quantity to the internal object valueproductcalculate the product with the internal object valuedivisioncalculate the division with the internal object valuemodulecalculate the module of a division with the internal object valueexponentcalculate the exponent of the internal object value to the indicated exponentrootcalculate the root of the internal object value to the indicated degree, square by defaultpercentcalculate the indicated percentage of the internal object valueincreasePercentadd the indicated percentage of the internal object valuedecreasePercentdown the indicated percentage of the internal object valueroundHalfUproundHalfDownroundAwayToZeroroundAwayFromZeroroundToHighIntegerroundToLowIntegerminpass an array or floats list and return the min including the internal value into the comparationmaxpass an array or floats list and return the max including the internal value into the comparation```
echo (string)(NumbersManipulators($pvu = 100))
    ->product($units = 10)
    ->increasePercent($taxes = 21);

//1210
```

### Date + Times

[](#date--times)

Check, parse a value as a date from some origins and formats, and retunrs a DateTime instance

#### Create from excel time value

[](#create-from-excel-time-value)

```
echo  (new DateManipulators())
    ->fromExcel(46023)
    ->format("Y-m-d");

// 2026-01-01
```

#### Create from timestamp

[](#create-from-timestamp)

```
echo  (new DateManipulators())
    ->fromTimestamp(1735689600)
    ->format("Y-m-d");

// 2026-01-01
```

#### Create from string

[](#create-from-string)

```
echo  (new DateManipulators())
    ->fromString("Thursday, 01-Jan-26 00:00:00 UTC")
    ->format("Y-m-d");

// 2026-01-01
```

#### Create from knowed format

[](#create-from-knowed-format)

```
echo  (new DateManipulators())
    ->fromFormatString(20260101, "Ymd")
    ->format("Y-m-d");

// 2026-01-01
```

Sanitizers
----------

[](#sanitizers)

Filter, clean and convert contents variables, for use from forms, file contents, DTOs or other origins

- Strings
- Numbers

### Strings

[](#strings-1)

#### Clean Email

[](#clean-email)

[FILTER\_SANITIZE\_EMAIL](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-email).

```
$sanitizer = (new StringSanitizers())->email();
echo $sanitizer('Juan. Sanchez@tecnicosweb.com'); //Juan.Sanchez@tecnicosweb.com
```

#### Clean URL

[](#clean-url)

[FILTER\_SANITIZE\_URL](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-url).

#### Add Slashes

[](#add-slashes)

[FILTER\_SANITIZE\_ADD\_SLASHES](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-add-slashes).

```
$sanitizer = (new StringSanitizers())->addSlashes();
echo $sanitizer('SELECT * FROM "table"'); //SELECT * FROM \"table\"
```

#### HTML Special Chars

[](#html-special-chars)

[FILTER\_SANITIZE\_FULL\_SPECIAL\_CHARS](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-full-special-chars).

```
$sanitizer = (new StringSanitizers())->htmlSpecialChars();
echo $sanitizer('Text'); //&lt;div&gt;Text&lt;/div&gt;
```

#### Strip HTML Tags

[](#strip-html-tags)

[strip\_tags](https://www.php.net/manual/es/function.strip-tags.php).

```
$sanitizer = (new StringSanitizers())->stripTags();
echo $sanitizer('Text'); //Text
```

#### Combine Sanitizators

[](#combine-sanitizators)

```
$sanitizator= (new StringSanitizers())->stripTags()->htmlSpecialChars();
echo $sanitizator("Camión&\r\n"); //"Cami&oacute;n&amp;\r\n"
```

### Extended String Sanitizators

[](#extended-string-sanitizators)

#### setStripBacktick

[](#setstripbacktick)

Remove or not the backtick character, an executor for unix terminals, in order to avoid code execution

#### setStripChars

[](#setstripchars)

You can indicate if would remove the control ASCII chars (less than 32) or the extended ASCII codes (greather than 127)

#### setEncodeChars

[](#setencodechars)

You can indicate if would encode the control ASCII chars (less than 32) or the extended ASCII codes (greather than 127)

#### unsafe

[](#unsafe)

[FILTER\_UNSAFE\_RAW](https://www.php.net/manual/es/filter.constants.php#constant.filter-unsafe-raw).+ FILTER\_FLAG\_EMPTY\_STRING\_NULL

#### safe

[](#safe)

[FILTER\_SANITIZE\_SPECIAL\_CHARS](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-special-chars). + FILTER\_FLAG\_EMPTY\_STRING\_NULL

#### urlEncode

[](#urlencode)

[FILTER\_SANITIZE\_ENCODED](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-encoded). + FILTER\_FLAG\_EMPTY\_STRING\_NULL

#### hmtlEncode

[](#hmtlencode)

[FILTER\_SANITIZE\_SPECIAL\_CHARS](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-special-chars). + FILTER\_FLAG\_EMPTY\_STRING\_NULL + FILTER\_FLAG\_ENCODE\_AMP

```
$sanitizator= (new StringSanitizers())->stripTags()->htmlSpecialChars();
echo $sanitizator("Camión&\r\n"); //"Cami&oacute;n&amp;\r\n"
```

### Numbers

[](#numbers-1)

Can extract and parse from an origin, the numeric part, extracting the integer or float contained, removing (or not) the thousand separators. Into code, the colon is a parameters separator, for this reason, by default, we don't preserve it, but you can preserve thousand separator pasing TRUE.

### Floats

[](#floats)

[FILTER\_SANITIZE\_NUMBER\_FLOAT](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-number-float). + FILTER\_FLAG\_ALLOW\_THOUSAND

```
$sanitizer = (new NumberSanitizers())->float($with_thousand_separator = false);
echo $sanitizer('2,000.22€'); //2000.22
```

### Integers

[](#integers)

[FILTER\_SANITIZE\_NUMBER\_INT](https://www.php.net/manual/es/filter.constants.php#constant.filter-sanitize-number-int). + FILTER\_FLAG\_ALLOW\_THOUSAND

```
$sanitizer = (new NumberSanitizers())->integer($with_thousand_separator = false);
echo $sanitizer('Z123456789N'); //123456789
```

> For integer sanitization, the FILTER\_FLAG\_ALLOW\_FRACTION is not used, allways perform a number\_format with 0 fraction for remove the decimals, taken only the integer part, not just removing dot

```
$sanitizer = (new NumberSanitizers())->integer($with_thousand_separator = false);
echo $sanitizer('2,000.22€'); //2000
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance81

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

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

Total

4

Last Release

100d ago

### Community

Maintainers

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

---

Top Contributors

[![JuanchoSL](https://avatars.githubusercontent.com/u/18701207?v=4)](https://github.com/JuanchoSL "JuanchoSL (23 commits)")

---

Tags

manipulationstringsvariablesnumbersarrays

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juanchosl-datamanipulation/health.svg)

```
[![Health](https://phpackages.com/badges/juanchosl-datamanipulation/health.svg)](https://phpackages.com/packages/juanchosl-datamanipulation)
```

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M712](/packages/doctrine-inflector)[delight-im/random

The most convenient way to securely generate anything random in PHP

2345.4k](/packages/delight-im-random)

PHPackages © 2026

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