PHPackages                             commandstring/utils - 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. commandstring/utils

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

commandstring/utils
===================

A collection of useful PHP utilities

v1.7.2(3y ago)21.7k2[1 issues](https://github.com/CommandString/Utils/issues)8MITPHP

Since Nov 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/CommandString/Utils)[ Packagist](https://packagist.org/packages/commandstring/utils)[ RSS](/packages/commandstring-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (8)

CommandString/Utils
===================

[](#commandstringutils)

Basic utility functions for PHP

ArrayUtils
==========

[](#arrayutils)

```
toStdClass(array $array): stdClass
```

Converts array to an stdClass

```
$users = [
    "value" => [
        "users" => [
            [
                "username" => "user",
                "password" => "********",
                "email" => "user@example.com"
            ]
        ]
    ],
    "token" => "********************************"
];

$users = ArrayUtils::toStdClass($users);

var_dump($users);
/* output
object(stdClass)#2 (2) {
    ["value"]=>
    object(stdClass)#4 (1) {
        ["users"]=>
        object(stdClass)#5 (1) {
        ["0"]=>
        object(stdClass)#6 (3) {
            ["username"]=>
            string(4) "user"
            ["password"]=>
            string(8) "********"
            ["email"]=>
            string(16) "user@example.com"
        }
        }
    }
    ["token"]=>
    string(32) "********************************"
}
*/
```

---

```
randomize(array $array): array
```

randomizes the given array

```
$characters = str_split("Command_String");
$randomized_characters = ArrayUtils::randomize($characters);

foreach ($randomized_characters as $character) {
    echo $character;
}
```

StringUtils
===========

[](#stringutils)

```
getBetween(string $start, string $end, string $string, bool $include_start_end_with_response = false): string
```

Gets text between to specified points in a string and returns it.

```
$greeting = "My name is Bob! What's yours?";

$name = StringUtils::getBetween("is ", "!", $greeting);

echo $name; // output: Bob
```

***If*** you want the start and end to be returned you can set the fourth argument to true, a good use case for this would be parsing a json string out of a blob of text

```
$text = 'fdsjhyasdfuygfdsuygfduygfsd{"name": "Bob"}asduygasduyauysduytasduy?';

$json = StringUtils::getBetween("{", "}", $text, true);

echo $json; // output: {"name": "Bob"}

var_dump(json_decode($json));
/* output:
object(stdClass)#3 (1) {
  ["name"]=>
  string(5) "Bob"
}
*/
```

GeneratorUtils
==============

[](#generatorutils)

```
uuid(int $length = 16, array $characters = []): string
```

Generates a UUID.

Generically the method will return a 16 character alphanumeric string

```
echo GeneratorUtils::uuid(); // output: 6MwqCff0wdpUl1sdw
```

You can adjust the length as needed

```
echo GeneratorUtils::uuid(5); // output: 8zWgWw
```

You can also supply characters for the generator to use

```
echo GeneratorUtils::uuid(10, [1, 0]); // output: 11110100100
```

FileSystemUtils
===============

[](#filesystemutils)

```
getAllFiles(string $directory, bool $recursive = false): array
```

Get all files in a directory, if the second parameter is true then files in subdirectories will be included in the returned array

---

```
getAllSubDirectories(string $directory, bool $recursive = false): array
```

Get all subdirectories in a directory and if recursive is true all subdirectories of the subdirectories will be included

---

```
getAllFilesWithExtensions(string $directory, array $extensionsToFind, bool $recursive = false): array
```

Get all files in a directory with one of the supplied extensions. If the third parameter is true then the directories' subdirectories will be searched as well.

---

ColorUtils
==========

[](#colorutils)

```
RGBAtoHEX(int $red, int $blue, int $green, ?int $alpha = null): string
```

Converts a RGBA color code to a HEX color code

---

```
HEXtoRGBA(string $hex): array
```

Converts a HEX color code to a RGBA color code.

---

FileSizeUtils
=============

[](#filesizeutils)

```
convertFileSize(FileSizeUtils $from_type, FileSizeUtils $to_type, float $from_size): float
```

Convert a file size from one type to another

---

```
humanReadable(FileSizeUtils $type, float $size, int $decimals = 0): string
```

Creates reduces the format that appends to type abbreviation to the end.

```
echo FileSizeUtils::humanReadable(FileSizeUtils::MEGABYTE, 5000); // output: 5 GB
```

---

```
reduceFileSize(FileSizeUtils $type, float $size): stdClass
```

Reduces a file size to the smallest it can be before being smaller than 1. An stdClass with a type property is then returned alongside a size property for the new size.

```
var_dump(FileSizeUtils::humanReadable(FileSizeUtils::MEGABYTE, 5000));
/**
 *  object(stdClass)#12 (2) {
 *  ["type"]=>
 *      enum(CommandString\Utils\FileSizeUtils::GIGABYTE)
 *  ["size"]=>
 *      float(5)
 *  }
 */
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.9% 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 ~17 days

Recently: every ~29 days

Total

10

Last Release

1113d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1dc8515485fa64088fdfa03dd0f487d507dc1516824c31be2626a6ee25244dd?d=identicon)[command\_string](/maintainers/command_string)

---

Top Contributors

[![CommandString](https://avatars.githubusercontent.com/u/44886996?v=4)](https://github.com/CommandString "CommandString (68 commits)")[![freezemage0](https://avatars.githubusercontent.com/u/48737675?v=4)](https://github.com/freezemage0 "freezemage0 (7 commits)")[![TheForestSystem](https://avatars.githubusercontent.com/u/63935304?v=4)](https://github.com/TheForestSystem "TheForestSystem (7 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/commandstring-utils/health.svg)

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

###  Alternatives

[scify/laravel-cookie-guard

A Laravel package that provides a Cookies consent floating window and publishes the Cookies for the different consent categories

13714.3k](/packages/scify-laravel-cookie-guard)[iceicetimmy/acf-post-type-selector

Post type selector for Advanced Custom Fields.

559.0k](/packages/iceicetimmy-acf-post-type-selector)

PHPackages © 2026

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