PHPackages                             effectra/to-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. effectra/to-string

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

effectra/to-string
==================

The Effectra ToString package.

v1.2.0(1y ago)0302MITPHP

Since May 25Pushed 1y agoCompare

[ Source](https://github.com/effectra/to-string)[ Packagist](https://packagist.org/packages/effectra/to-string)[ RSS](/packages/effectra-to-string/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (3)DependenciesVersions (3)Used By (2)

to-string PHP Library
=====================

[](#to-string-php-library)

`to-string` is a PHP library that provides various utility classes for string manipulation and conversion. It offers functionality to convert text case, strip tags, generate slugs, format arrays, and handle date/time values.

Installation
------------

[](#installation)

You can install the `to-string` library via Composer. Run the following command in your project directory:

```
composer require effectra/to-string

```

Usage
-----

[](#usage)

### TextToString

[](#texttostring)

#### `toUppercase(string $text): string`

[](#touppercasestring-text-string)

Converts a string to uppercase.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->toUppercase('Hello, World!');
echo $result; // Output: HELLO, WORLD!
```

#### `toLowercase(string $text): string`

[](#tolowercasestring-text-string)

Converts a string to lowercase.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->toLowercase('Hello, World!');
echo $result; // Output: hello, world!
```

#### `strip(string $text): string`

[](#stripstring-text-string)

Strips HTML and PHP tags from a string.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->strip('Hello, World!');
echo $result; // Output: Hello, World!
```

#### `nameVar($variable): string`

[](#namevarvariable-string)

Extracts the variable name from the caller's context.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$myVariable = 'Hello, World!';
$result = $textToString->nameVar($myVariable);
echo $result; // Output: myVariable
```

#### `textToSlug($text): string`

[](#texttoslugtext-string)

Converts a string to a URL-friendly slug.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->textToSlug('Hello, World!');
echo $result; // Output: hello-world
```

#### `slugToText($slug): string`

[](#slugtotextslug-string)

Converts a URL-friendly slug back to readable text.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->slugToText('hello-world');
echo $result; // Output: Hello World
```

#### `generateRandomText($length): string`

[](#generaterandomtextlength-string)

Generates a random text of specified length.

```
use Effectra\ToString\TextToString;

$textToString = new TextToString();
$result = $textToString->generateRandomText(8);
echo $result; // Output: C4rN1QX7
```

### ArrayToString

[](#arraytostring)

#### `array(array $array): string`

[](#arrayarray-array-string)

Converts an array to a string representation.

```
use Effectra\ToString\ArrayToString;

$result = ArrayToString::array(['apple', 'banana', 'cherry']);
echo $result; // Output: ['apple', 'banana', 'cherry']
```

#### `arrayToText(array $data, string $separator = ','): string`

[](#arraytotextarray-data-string-separator---string)

Converts an array to a string by joining its elements with a separator.

```
use Effectra\ToString\ArrayToString;

$result = ArrayToString::arrayToText(['apple', 'banana', 'cherry']);
echo $result; // Output: apple,banana,cherry
```

#### `arrayToSlug(array $data): string`

[](#arraytoslugarray-data-string)

Converts an array to a URL-friendly slug by joining its elements with a separator.

```
use Effectra\ToString\ArrayToString;

$arrayToString = new ArrayToString();
$result = $arrayToString->arrayToSlug(['apple', 'banana', 'cherry']);
echo $result; // Output: apple-banana-cherry
```

#### `arrayToTextKeyValue($data): string`

[](#arraytotextkeyvaluedata-string)

Converts an array or JSON string to a key-value pair string representation.

```
use Effectra\ToString\ArrayToString;

$arrayToString = new ArrayToString();
$result = $arrayToString->arrayToTextKeyValue(['name' => 'John', 'age' => 25, 'city' => 'New York']);
echo $result;
/*
Output:
name: John,
age: 25,
city: New York,
*/
```

### DateToString

[](#datetostring)

#### `formatTime(int $time): string`

[](#formattimeint-time-string)

Formats a time value in seconds into HH:MM:SS format.

```
use Effectra\ToString\DateToString;

$dateToString = new DateToString();
$result = $dateToString->formatTime(3600); // Assuming 3600 seconds is 1 hour
echo $result; // Output: 01:00:00
```

#### `formatDate(int $timestamp): string`

[](#formatdateint-timestamp-string)

Formats a timestamp into YYYY-MM-DD format.

```
use Effectra\ToString\DateToString;

$dateToString = new DateToString();
$result = $dateToString->formatDate(time()); // Current timestamp
echo $result; // Output: 2023-05-13
```

License
-------

[](#license)

This library is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.

Contributing
------------

[](#contributing)

Contributions are welcome! If you have any improvements or bug fixes, please submit a pull request.

Credits
-------

[](#credits)

The `to-string` library is developed and maintained by [Effectra](https://effectra.co/).

Support
-------

[](#support)

For any questions or issues, please [open an issue](https://github.com/effectra/to-string/issues) on GitHub.

Feel free to modify the README file according to your specific library details, such as author information, additional sections, or formatting preferences.

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

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

Total

2

Last Release

619d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e6219ae87e98df8783b2f595b013035dd183c0712afd24045a8acf0a40c3bdf?d=identicon)[effectra](/maintainers/effectra)

---

Top Contributors

[![BMTmohammedtaha](https://avatars.githubusercontent.com/u/95439605?v=4)](https://github.com/BMTmohammedtaha "BMTmohammedtaha (18 commits)")

---

Tags

phpstring-formatterstring-manipulationtext-processing

### Embed Badge

![Health badge](/badges/effectra-to-string/health.svg)

```
[![Health](https://phpackages.com/badges/effectra-to-string/health.svg)](https://phpackages.com/packages/effectra-to-string)
```

###  Alternatives

[josantonius/session

PHP library for handling sessions.

7826.9k5](/packages/josantonius-session)[mimicreative/yii2-react

ReactJS Asset Bundle for Yii2

131.7k](/packages/mimicreative-yii2-react)

PHPackages © 2026

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