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

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

parables/php-utils
==================

a set of frequently used helper functions

0.1.2(11mo ago)1432MITPHP

Since May 26Pushed 11mo ago1 watchersCompare

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

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

php-utils
=========

[](#php-utils)

A set of handy php functions

Usage
-----

[](#usage)

All `Util::method()` are also exposed as global functions. In order to avoid conflicts with already declared functions with the same name, the global functions are wrapped in an `if (! function_exists('fn_name')) {` block.

```
// StringUtils

normalize_whitespace(...$args)
capitalize(...$args)
instance_or_default(...$args)
slugify(...$args)
words(...$args)
is_all_upper_case(...$args)
pascal_case(...$args)
camel_case(...$args)
snake_case(...$args)
kebab_case(...$args)
excel_date_to_php_date(...$args)
array_flatten(...$args)
array_keys_transform(...$args)
array_unique_value(...$args)
is_url(...$args)
is_valid_url(...$args)
```

### String Utils

[](#string-utils)

1. `normalizeWhitespace(string $str = '')`

Removes extra whitespace and trims the string.

```
$str = "  This string \n has \t extra  \v   spaces .   ";
$normalizedStr = Utils::normalizeWhitespace($str);
// $normalizedStr = "This string has extra spaces .";
```

2. `capitalize(string $str = '')`

Capitalizes first letter of each word, lowercase rest.

```
$str = "this SENTENCE needs CAPITALIZATION!";
$capitalizedStr = Utils::capitalize($str);
// $capitalizedStr = "This Sentence Needs Capitalization";
```

3. `slugify(string $str = '', bool $toLower = true)`

Converts to URL-friendly format with dashes/underscores. Optional toLower controls lowercase conversion.

```
$str = "My Awesome Product Name!";
$slug = Utils::slugify($str);
// $slug = "my-awesome-product-name";

$slugWithUppercase = Utils::slugify($str, false);
// $slugWithUppercase = "My-Awesome-Product-Name";
```

4. `words(string $str = '')`

Splits into an array of words, preserving capitalization for single words.

```
$str = "This is a sentence with multiple words.";
$words = Utils::words($str);
// $words = ["This", "Is", "A", "Sentence", "With", "Multiple", "Words"];
```

5. `isAllUpperCase(string $str)`

Checks if all characters are uppercase.

```
$str = "ALL UPPERCASE";
$isAllUpper = Utils::isAllUpperCase($str); // true

$str = "Not All Uppercase";
$isAllUpper = Utils::isAllUpperCase($str); // false
```

6. `pascalCase(string $str = '')`

Converts to PascalCase (all words start with uppercase).

```
$str = "this is a string";
$pascalCase = Utils::pascalCase($str);
// $pascalCase = "ThisIsString";
```

7. `camelCase(string $str = '')`

Converts to camelCase (first word lowercase, others uppercase).

```
$str = "This is a string";
$camelCase = Utils::camelCase($str);
// $camelCase = "thisIsAString";
```

8. `snakeCase(string $str = '')`

Converts to snake\_case (lowercase with underscores).

```
$str = "This is a string";
$snakeCase = Utils::snakeCase($str);
// $snakeCase = "this_is_a_string";
```

9. `kebabCase(string $str)`

Converts to kebab-case (lowercase with hyphens).

```
$str = "This is a string";
$kebabCase = Utils::kebabCase($str);
// $kebabCase = "this-is-a-string";
```

10. `isUrl(string $url)`

Basic URL validation using built-in functions.

```
$url = "https://www.example.com";
$isUrlValid = Utils::isUrl($url); // true

$url = "invalid-url";
$isUrlValid = Utils::isUrl($url); // false
```

11. `isValidUrl(string $url)`

Performs more rigorous URL validation with parsing and hostname checks.

```
$url = "https://www.example.com";
$isValidUrl = Utils::isValidUrl($url); // true

$url = "invalid-url";
$isValidUrl = Utils::isValidUrl($url); // false
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance51

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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

Total

4

Last Release

344d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61002a21b32e3d7b7ab37fdadce9532c5307dea5541048a5bdea24de573bf457?d=identicon)[parables](/maintainers/parables)

---

Top Contributors

[![Parables](https://avatars.githubusercontent.com/u/38154990?v=4)](https://github.com/Parables "Parables (10 commits)")

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[omaralalwi/laravel-trash-cleaner

clean logs and debug files (clockwork , laravel telescope and more)

221.8k](/packages/omaralalwi-laravel-trash-cleaner)

PHPackages © 2026

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