PHPackages                             farzai/support - 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. farzai/support

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

farzai/support
==============

A collection of useful PHP functions, helpers, and classes.

1.4.0(8mo ago)05.4k[3 PRs](https://github.com/farzai/support-php/pulls)2MITPHPPHP ^8.0CI passing

Since May 31Pushed 2mo agoCompare

[ Source](https://github.com/farzai/support-php)[ Packagist](https://packagist.org/packages/farzai/support)[ Docs](https://github.com/farzai/support-php)[ GitHub Sponsors](https://github.com/parsilver)[ RSS](/packages/farzai-support/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (6)Dependencies (6)Versions (11)Used By (2)

Support Package - PHP
=====================

[](#support-package---php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/74045e9d1272589cbec78fbc32ecc37e462d11c403a6945264e4285692172719/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661727a61692f737570706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/support)[![Tests](https://camo.githubusercontent.com/fdc23c176b567375a2986d2b6bafed6ed5e9e5941941fa966756575e3a6d052f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6661727a61692f737570706f72742d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/farzai/support-php/actions/workflows/run-tests.yml)[![codecov](https://camo.githubusercontent.com/9659e41ae0790fbb0d7cc233ce65a4f15e132c3401ab35e18fe653d698621b3b/68747470733a2f2f636f6465636f762e696f2f67682f6661727a61692f737570706f72742d7068702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/farzai/support-php)[![Total Downloads](https://camo.githubusercontent.com/49b4a037865a091919de3f9751fd682d385f8ac20e7d6808ed6b56cbec679dc9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661727a61692f737570706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/support)

A collection of useful PHP helper functions and utilities with full type safety and comprehensive documentation.

Features
--------

[](#features)

- 🔒 **Fully Typed** - Complete PHP 8.0+ type declarations for enhanced IDE support
- 📝 **Well Documented** - Comprehensive PHPDoc comments with examples
- ✅ **Thoroughly Tested** - High test coverage with edge case testing
- 🔍 **Static Analysis** - PHPStan Level 8 compliant
- 🎯 **Zero Dependencies** - Only requires Carbon for date/time utilities
- 🌐 **UTF-8 Safe** - Multi-byte string operations throughout

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- ext-mbstring

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

[](#installation)

You can install the package via composer:

```
composer require farzai/support
```

Table of Contents
-----------------

[](#table-of-contents)

- [Array Utilities](#array-utilities)
- [String Utilities](#string-utilities)
- [Date/Time Utilities](#datetime-utilities)
- [Helper Functions](#helper-functions)

Array Utilities
---------------

[](#array-utilities)

The `Arr` class provides utilities for working with arrays using dot notation.

### get()

[](#get)

Get an item from an array using dot notation:

```
use Farzai\Support\Arr;

$array = [
    'user' => [
        'name' => 'John Doe',
        'email' => 'john@example.com',
        'address' => [
            'city' => 'New York'
        ]
    ]
];

// Get nested value
Arr::get($array, 'user.name'); // Returns: 'John Doe'
Arr::get($array, 'user.address.city'); // Returns: 'New York'

// With default value
Arr::get($array, 'user.phone', 'N/A'); // Returns: 'N/A'

// Get entire array
Arr::get($array, null); // Returns: entire $array
```

### exists()

[](#exists)

Check if a key exists in an array using dot notation:

```
use Farzai\Support\Arr;

$array = ['user' => ['name' => 'John']];

Arr::exists($array, 'user.name'); // Returns: true
Arr::exists($array, 'user.email'); // Returns: false
```

### accessible()

[](#accessible)

Check if a value is array accessible:

```
use Farzai\Support\Arr;

Arr::accessible(['foo' => 'bar']); // Returns: true
Arr::accessible(new ArrayObject()); // Returns: true
Arr::accessible('string'); // Returns: false
```

String Utilities
----------------

[](#string-utilities)

The `Str` class provides a rich set of string manipulation methods.

### Case Conversion

[](#case-conversion)

```
use Farzai\Support\Str;

// camelCase
Str::camel('foo_bar'); // Returns: 'fooBar'
Str::camel('foo-bar'); // Returns: 'fooBar'

// StudlyCase (PascalCase)
Str::studly('foo_bar'); // Returns: 'FooBar'

// snake_case
Str::snake('fooBar'); // Returns: 'foo_bar'
Str::snake('FooBar', '-'); // Returns: 'foo-bar'

// lowercase
Str::lower('FOO BAR'); // Returns: 'foo bar'
```

### Case Checking

[](#case-checking)

```
use Farzai\Support\Str;

Str::isSnakeCase('foo_bar'); // Returns: true
Str::isCamelCase('fooBar'); // Returns: true
Str::isStudlyCase('FooBar'); // Returns: true
```

### String Operations

[](#string-operations)

```
use Farzai\Support\Str;

// Replace
Str::replace('foo', 'bar', 'foo baz'); // Returns: 'bar baz'

// Check if starts with
Str::startsWith('foobar', 'foo'); // Returns: true
Str::startsWith('foobar', ['bar', 'foo']); // Returns: true

// Check if ends with
Str::endsWith('foobar', 'bar'); // Returns: true

// Check if contains
Str::contains('foobar', 'oob'); // Returns: true
Str::contains('foobar', ['baz', 'bar']); // Returns: true

// Length (UTF-8 safe)
Str::length('foo'); // Returns: 3
Str::length('ñoño'); // Returns: 4

// Substring (UTF-8 safe)
Str::substr('foobar', 0, 3); // Returns: 'foo'
Str::substr('foobar', 3); // Returns: 'bar'
```

### Random String Generation

[](#random-string-generation)

All random methods use cryptographically secure randomness:

```
use Farzai\Support\Str;

// Random alphanumeric (base64-like)
Str::random(16); // Returns: 'a3K7mN9pQ1xY2zB5'

// Random ASCII
Str::randomAscii(16);

// Random numeric only
Str::randomNumeric(6); // Returns: '472891'

// Random alphanumeric (A-Z, a-z, 0-9)
Str::randomAlphanumeric(12); // Returns: 'aB3xY9mK2nP7'

// Random with custom character set
Str::randomString(8, 'ABCD123'); // Returns: 'A2B1C3D2'

// Random with special characters (for passwords)
Str::randomStringWithSpecialCharacter(16); // Returns: 'aB3!xY@9#mK2$pQ5'
```

Date/Time Utilities
-------------------

[](#datetime-utilities)

The `Carbon` class extends the popular Carbon library with additional convenience methods.

### Creating Instances

[](#creating-instances)

```
use Farzai\Support\Carbon;
use function Farzai\Support\now;

// Get current date/time
$now = now();
// or
$now = Carbon::now();

// With timezone
$now = now('America/New_York');
$now = Carbon::now('UTC');

// From timestamp
$date = Carbon::fromTimestamp(1609459200);
```

### Date Checking

[](#date-checking)

```
use Farzai\Support\Carbon;

$today = Carbon::now();
$yesterday = Carbon::yesterday();
$tomorrow = Carbon::tomorrow();

// Check if today
$today->isToday(); // Returns: true
$yesterday->isToday(); // Returns: false

// Check if past
$yesterday->isPast(); // Returns: true
$tomorrow->isPast(); // Returns: false

// Check if future
$tomorrow->isFuture(); // Returns: true
$yesterday->isFuture(); // Returns: false

// Check if between dates
$today->isBetweenDates($yesterday, $tomorrow); // Returns: true
```

### Date Formatting

[](#date-formatting)

```
use Farzai\Support\Carbon;

$date = Carbon::now();

// Format as date string
$date->toDateString(); // Returns: '2024-03-18'

// Format as time string
$date->toTimeString(); // Returns: '14:30:45'

// Format as datetime string
$date->toDateTimeString(); // Returns: '2024-03-18 14:30:45'
```

### Day Boundaries

[](#day-boundaries)

```
use Farzai\Support\Carbon;

$date = Carbon::now();

// Start of day
$start = $date->startOfDay(); // Returns: today at 00:00:00

// End of day
$end = $date->endOfDay(); // Returns: today at 23:59:59
```

### Date Differences

[](#date-differences)

```
use Farzai\Support\Carbon;

$today = Carbon::now();
$yesterday = Carbon::yesterday();

// Absolute difference in days
$today->diffInDaysAbsolute($yesterday); // Returns: 1
```

Helper Functions
----------------

[](#helper-functions)

Global helper functions in the `Farzai\Support` namespace.

### tap()

[](#tap)

Execute a callback on a value and return the value:

```
use function Farzai\Support\tap;

// With callback
$user = tap($user, function ($u) {
    $u->update(['last_login' => now()]);
});
// Returns $user after updating

// Without callback (higher-order proxy)
$user = tap($user)
    ->update(['last_login' => now()])
    ->save();
// Chains methods but returns $user
```

### now()

[](#now)

Get the current date/time:

```
use function Farzai\Support\now;

$current = now(); // Returns: Carbon instance
$ny = now('America/New_York'); // Returns: Carbon instance in NY timezone
```

### class\_basename()

[](#class_basename)

Get the class name without namespace:

```
use function Farzai\Support\class_basename;

class_basename('App\Models\User'); // Returns: 'User'
class_basename(new \App\Models\User); // Returns: 'User'
```

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
composer test
```

### Running Tests with Coverage

[](#running-tests-with-coverage)

```
composer test-coverage
```

### Code Formatting

[](#code-formatting)

```
composer format
```

### Static Analysis

[](#static-analysis)

```
composer analyze
```

### Run All Checks

[](#run-all-checks)

```
composer check
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/farzai/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [parsilver](https://github.com/parsilver)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance76

Regular maintenance activity

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.7% 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 ~175 days

Total

6

Last Release

243d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4928451?v=4)[parsilver](/maintainers/parsilver)[@parsilver](https://github.com/parsilver)

---

Top Contributors

[![parsilver](https://avatars.githubusercontent.com/u/4928451?v=4)](https://github.com/parsilver "parsilver (34 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")

---

Tags

supportfarzai

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/farzai-support/health.svg)

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

###  Alternatives

[illuminate/support

The Illuminate Support package.

582110.9M39.8k](/packages/illuminate-support)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

293943.4k27](/packages/craftcms-feed-me)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

53675.5k15](/packages/solspace-craft-freeform)[padosoft/support

agnostic helpers to use as foundation in packages and other project

5117.9k5](/packages/padosoft-support)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)[japanese-date/japanese-date

日本の暦、祝日を取り扱うライブラリ

169.9k](/packages/japanese-date-japanese-date)

PHPackages © 2026

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