PHPackages                             corpsee/nameless-utilities - 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. corpsee/nameless-utilities

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

corpsee/nameless-utilities
==========================

PHP Utilities compliant with PSR-1, PSR-2, PSR-4 and Composer

3.0.1(7y ago)285011GPL-3.0-onlyPHPPHP &gt;=7.1.0

Since Sep 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/corpsee/nameless-utilities)[ Packagist](https://packagist.org/packages/corpsee/nameless-utilities)[ Docs](https://github.com/corpsee/nameless-utilities)[ RSS](/packages/corpsee-nameless-utilities/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (19)Used By (1)

[![PHP Censor](https://camo.githubusercontent.com/17ddd502274b90ce87fc49803154b467b7f4ec2867fc9d3642efd137bf6b4331/687474703a2f2f63692e7068702d63656e736f722e696e666f2f6275696c642d7374617475732f696d6167652f343f6272616e63683d6d6173746572266c6162656c3d50485043656e736f72267374796c653d666c61742d737175617265)](http://ci.php-censor.info/build-status/view/4?branch=master)[![Travis CI](https://camo.githubusercontent.com/dc75fbb4a7cb75f8466451f86a5ec8f9f08be8e5aef2642e82016d0c36be348b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f72707365652f6e616d656c6573732d7574696c69746965732f6d61737465722e7376673f6c6162656c3d5472617669734349267374796c653d666c61742d737175617265)](https://travis-ci.org/corpsee/nameless-utilities?branch=master)[![SensioLabs Insight](https://camo.githubusercontent.com/3755e9708ab8fd502b8890ac04fb9dbf62d1079434c296cffe029854d55dac1b/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f62306634333133352d383336322d343630312d386131312d6166663032336665333831352e7376673f6c6162656c3d496e7369676874267374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/b0f43135-8362-4601-8a11-aff023fe3815)[![Codecov](https://camo.githubusercontent.com/acceed49b5e8e0aaec4cd53f38e04c6771f4c095f040f3d3d24a89ff78205d07/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f636f72707365652f6e616d656c6573732d7574696c69746965732e7376673f6c6162656c3d436f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/corpsee/nameless-utilities)[![Latest Version](https://camo.githubusercontent.com/fa615f66a41c823ff42926103d4be92e1481a0fb5ef94252a99771faea2187d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f72707365652f6e616d656c6573732d7574696c69746965732e7376673f6c6162656c3d56657273696f6e267374796c653d666c61742d737175617265)](https://packagist.org/packages/corpsee/nameless-utilities)[![Total downloads](https://camo.githubusercontent.com/9179b196bd52b71e92eb96b132442419e739507da7b8a13c2ee39b8cb52dd50e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f72707365652f6e616d656c6573732d7574696c69746965732e7376673f6c6162656c3d446f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/corpsee/nameless-utilities)[![License](https://camo.githubusercontent.com/de56a6b95ee14176fdc7bddf3c3c5e26d5c435203444b60a2a8577a095b8a2fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f72707365652f6e616d656c6573732d7574696c69746965732e7376673f6c6162656c3d4c6963656e7365267374796c653d666c61742d737175617265)](https://packagist.org/packages/corpsee/nameless-utilities)

**This package is abandoned and no longer maintained.**

Nameless utilities
==================

[](#nameless-utilities)

PHP Utilities compliant with PSR-1, PSR-2, PSR-4 and Composer.

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

[](#installation)

You can install Nameless utilities by composer. Add following code to "require" section of the `composer.json`:

```
"require": {
    "corpsee/nameless-utilities": ""
}
```

And install dependencies using the Composer:

```
cd path/to/your-project
composer install
```

Usage
-----

[](#usage)

### ArrayHelper

[](#arrayhelper)

```
use Nameless\Utilities\ArrayHelper;

echo ArrayHelper::toString([1, 2, 3]); // Prints '1, 2, 3', ', ' is default separator
echo ArrayHelper::toString([1, 2, 3], ':'); // Prints '1:2:3'

$array = [
    'one'   => 1,
    'two'   => 2,
    'three' => 3,
];
echo ArrayHelper::get($array, 'four', 4); // Prints '4' (4)
```

### DateTimeHelper

[](#datetimehelper)

```
use Nameless\Utilities\DateTimeHelper;

echo DateTimeHelper::humanize(121.001); // Prints '2 minute 1 second 1 millisecond'
```

Usage with localization/alternative labels:

```
use Nameless\Utilities\DateTimeHelper;

$localization = [
    ['мкс', 'мкс'],
    ['мс', 'мс'],
    ['с', 'с'],
    ['мин', 'мин'],
    ['ч', 'ч'],
    ['д', 'д'],
    ['мес', 'мес'],
    ['г', 'г'],
];

echo DateTimeHelper::humanize(121, $localization); // Prints '2 мин 1 с'
```

### FileSizeHelper

[](#filesizehelper)

```
use Nameless\Utilities\FileSizeHelper;

echo FileSizeHelper::humanize(1000000000); // Prints '953.67MB'
echo FileSizeHelper::unhumanize('954MB');  // Prints '1000341504' (bytes)
```

### PathHelper

[](#pathhelper)

```
use Nameless\Utilities\PathHelper;

echo PathHelper::toURL('/base/path/to/url', '/base'); // Prints '/path/to/url'
```

### StringHelper

[](#stringhelper)

```
use Nameless\Utilities\StringHelper;

var_dump(StringHelper::startWith('example', 'exa'));  // Prints true
var_dump(StringHelper::endWith('example', 'mplee'));  // Prints true
var_dump(StringHelper::contains('example', 'xampl')); // Prints true

echo StringHelper::cut('example', 6);             // Prints 'exampl...', '...' is default suffix
echo StringHelper::cutWords('simple example', 1); // Prints 'example...', '...' is default suffix

echo StringHelper::transliterate('очень простой пример', 'Russian-Latin/BGN');     // Prints transliterated 'ochen prostoj primer'
echo StringHelper::standardize('очень простой  Пример', 'Russian-Latin/BGN');      // Prints standardizated 'ochen_prostoj_primer', '_' is default words separator
echo StringHelper::standardize('очень простой  Пример', 'Russian-Latin/BGN', '-'); // Prints 'ochen-prostoj-primer', use '-' for slugify string

var_dump(StringHelper::toArray('1,2,3,')); // Prints Array ['1', '2', '3'], ',' is default separator

echo StringHelper::snakecaseToCamelcase('snake_case');       // Prints 'SnakeCase'
echo StringHelper::snakecaseToCamelcase('snake_case', true); // Prints 'snakeCase'
echo StringHelper::camelcaseToSnakecase('CamelCase');        // Prints 'camel_case'
```

### UrlHelper

[](#urlhelper)

```
use Nameless\Utilities\UrlHelper;

echo UrlHelper::toPath('/path/to/url', '/base'); // Prints '/base/path/to/url'
```

### BcMathHelper

[](#bcmathhelper)

Passing values of type float to a BCMath function which expects a string as operand may not have the desired effect due to the way PHP converts float values to string, namely that the string may be in exponential notation (what is not supported by BCMath), and that the decimal separator is locale depended (while BCMath always expects a decimal point).

```
