PHPackages                             jtc-solutions/helpers - 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. jtc-solutions/helpers

ActiveLibrary

jtc-solutions/helpers
=====================

Group of static helpers for type operations.

v0.2.0(1y ago)05.2k↓36.3%2proprietaryPHPPHP &gt;=8.3CI passing

Since Apr 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/JTC-Solutions/helpers)[ Packagist](https://packagist.org/packages/jtc-solutions/helpers)[ RSS](/packages/jtc-solutions-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (2)

JtcSolutions PHP Helpers Library
================================

[](#jtcsolutions-php-helpers-library)

A collection of helpful utility classes for common PHP tasks.

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

[](#installation)

(You'll need to add installation instructions here, typically using Composer)

```
composer require jtc-solutions/helpers
```

Usage
-----

[](#usage)

This library provides several static helper classes under the JtcSolutions\\Helpers\\Helper namespace.

### ArrayUtils

[](#arrayutils)

```
use JtcSolutions\Helpers\Helper\ArrayUtils;

// Check if an array contains duplicate values
$hasDuplicates = ArrayUtils::containsDuplicates([1, 2, 3, 2, 5]); // true
$noDuplicates = ArrayUtils::containsDuplicates(['a', 'b', 'c']); // false
```

### BatchUpdater

[](#batchupdater)

A helper class to determine which items need to be created, updated, or removed when comparing a list of existing entities with a list of input data transfer objects (DTOs) or similar structures. Useful for synchronizing data, especially collections within an aggregate root in DDD.

```
use JtcSolutions\Helpers\Helper\BatchUpdater;

// Assume $existingEntities is an array of your entity objects (e.g., from DB)
// Assume $inputDtos is an array of input data objects (e.g., from request)

// Example Entity & Input DTO (replace with your actual classes)
class MyEntity { public function __construct(public string $id, public string $data) {} }
class MyInput { public function __construct(public ?string $id, public string $data) {} }

$existingEntities = [
    new MyEntity('id1', 'old data 1'),
    new MyEntity('id2', 'old data 2'), // This one will be removed
    new MyEntity('id3', 'old data 3'), // This one will be updated
];

$inputDtos = [
    new MyInput('id1', 'old data 1'), // Unchanged (will be in update list)
    new MyInput('id3', 'new data 3'), // Needs update
    new MyInput(null, 'new data 4'),  // Needs creation
];

$entityIdGetter = fn(MyEntity $entity): string => $entity->id;
$inputIdGetter = fn(MyInput $input): ?string => $input->id;

$updater = new BatchUpdater($existingEntities, $entityIdGetter, $inputDtos, $inputIdGetter);

$idsToRemove = $updater->getIdsToRemove(); // ['id2']
$idsToUpdate = $updater->getIdsToBeUpdated(); // ['id1', 'id3']
$idsToCreate = $updater->getIdsToBeCreated(); // [generated_uuid_for_new_data_4]

// Access specific input/entity data using the ID
$inputForUpdate = $updater->getInput('id3'); // MyInput object with 'new data 3'
$entityForUpdate = $updater->getEntity('id3'); // MyEntity object with 'old data 3'
$inputForCreate = $updater->getInput($idsToCreate[0]); // MyInput object with 'new data 4'

// You can now loop through these IDs to perform persistence operations.
```

### ByteHelper

[](#bytehelper)

```
use JtcSolutions\Helpers\Helper\ByteHelper;

echo ByteHelper::formatBytes(1024);    // 1 KB
echo ByteHelper::formatBytes(1500000); // 1.43 MB
echo ByteHelper::formatBytes(0);       // 0 B
```

### FQCNHelper

[](#fqcnhelper)

Utilities for working with Fully Qualified Class Names (FQCNs), namespaces, and file paths. Assumes PSR-4 structure for conversions.

```
use JtcSolutions\Helpers\Helper\FQCNHelper;

$fqcn = "App\Domain\Entity\User";

// Extract 'domain' (2nd segment) and 'entity' (last segment)
$parts = FQCNHelper::extractDomainAndEntity($fqcn);
// $parts = ['domain' => 'Domain', 'entity' => 'User']

// Get short class name
$shortName = FQCNHelper::transformFQCNToShortClassName($fqcn); // "User"
$lowerShortName = FQCNHelper::transformFQCNToShortClassName($fqcn, true); // "user"

// Convert namespace to path
$path = FQCNHelper::convertNamespaceToFilepath($fqcn, "App", "src");
// $path = "src/Domain/Entity/User" (using / as separator)

// Convert path to namespace
$namespace = FQCNHelper::convertPathToNamespace("src/Service/AuthService", "App", "src");
// $namespace = "App\Service\AuthService"

// Extract namespace part from FQCN
$nsOnly = FQCNHelper::extractNamespaceFromFQCN($fqcn);
// $nsOnly = "App\Domain\Entity"
```

### StringUtils

[](#stringutils)

```
use JtcSolutions\Helpers\Helper\StringUtils;

// Case conversions
echo StringUtils::toKebabCase("helloWorldExample"); // hello-world-example
echo StringUtils::toSnakeCase("myVariableName");  // my_variable_name

// Lowercase / Sanitization
echo StringUtils::sanitizeLowercase("  Some String  "); // some string
echo StringUtils::toLowercase("UPPERCASE");          // uppercase
echo StringUtils::firstToLowercase("HelloWorld");    // helloWorld

// Random string generation
$random = StringUtils::generateUrlFriendlyString(10); // e.g., "a3b7x9p2q1"
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance47

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

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

Total

2

Last Release

399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b321740527037d9566e21683ab4b0a572d7b5b35a3a6e78fbfe9e1819cb047a?d=identicon)[davidjungman](/maintainers/davidjungman)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jtc-solutions-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/jtc-solutions-helpers/health.svg)](https://phpackages.com/packages/jtc-solutions-helpers)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k84.2M225](/packages/laravel-horizon)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[stancl/tenancy

Automatic multi-tenancy for your Laravel application.

4.3k6.6M40](/packages/stancl-tenancy)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)

PHPackages © 2026

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