PHPackages                             godsdev/tools - 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. godsdev/tools

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

godsdev/tools
=============

Pomocné funkce pro PHP

v0.4.0(3mo ago)07.2k12proprietaryPHPPHP &gt;=7.2 &lt;8.6CI passing

Since Sep 7Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/GodsDev/tools)[ Packagist](https://packagist.org/packages/godsdev/tools)[ Docs](https://github.com/GodsDev/tools)[ RSS](/packages/godsdev-tools/feed)WikiDiscussions master Synced 3w ago

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

Tools
=====

[](#tools)

A class with useful all-purpose functions (methods). The methods are static. Some methods for HTML-output adopt classes used in the [Bootstrap](http://getbootstrap.com) library.

[![Total Downloads](https://camo.githubusercontent.com/298fecc444409c1290411456aa1533a539315d5aef684ac3da6f50aebbf92f58/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f64736465762f746f6f6c732e737667)](https://packagist.org/packages/godsdev/tools)[![Latest Stable Version](https://camo.githubusercontent.com/aa96f7db168dfc6c697e1ff3b9ed7f0f01c326be9cf19e19797ea883dce30e01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676f64736465762f746f6f6c732e737667)](https://packagist.org/packages/godsdev/tools)[![Polish the code](https://github.com/GodsDev/tools/actions/workflows/polish-the-code.yml/badge.svg)](https://github.com/GodsDev/tools/actions/workflows/polish-the-code.yml)[![PHP Composer + PHPUnit + PHPStan](https://github.com/GodsDev/tools/actions/workflows/php-composer-dependencies.yml/badge.svg)](https://github.com/GodsDev/tools/actions/workflows/php-composer-dependencies.yml)

Deployment
----------

[](#deployment)

Once composer is installed, execute the following command in your project root to install this library:

```
composer require godsdev/tools:^0.4.0
```

The `composer.json` file should then contain current version of the class - something similar to:

```
{
  "require": {
    "godsdev/tools": "^0.4.0"
  }
}
```

Then be sure to include the autoloader:

```
require_once '/path/to/your-project/vendor/autoload.php';
```

Finally, include this line

```
use GodsDev\Tools\Tools;
```

to the **file** where you want to use Tools' methods. Then you can address all its function like this - `Tools::method()`.

Compatibility
-------------

[](#compatibility)

- PHP 5.6+, 7+
- several string-processing functions call `mb_XXXX` functions that require the `ext-mbstring` extension
- `relativeTime()` creates `new DateTime()`
- `stripAttributes()` uses `libxml` and creates `new DOMDocument()`, `new DOMXPath()`
- `str_putcsv()` opens the `"php://memory"` stream
- `curlCall()` uses cURL extension
- `webalize()` tests for `ext-iconv` extension and `iconv()` function

### Notes

[](#notes)

- Methods handling messages use session (`$_SESSION["messages"]` variable) for storing messages.
- `escapeSQL()` is obsolete and should not be used
- `escapeIn()` and `escapeDbIdentifier()` are specific to MySQL/MariaDb DBMS.

### PHP Extensions

[](#php-extensions)

The `"require"` item in `composer.json` should really be:

```
"require": {
    "php": "^5.6 || ^7.0",
    "ext-curl": "*",
    "ext-date": "*",
    "ext-dom": "*",
    "ext-iconv": "*",
    "ext-json": "*",
    "ext-mbstring": "*",
    "ext-pcre": "*",
    "ext-session": "*",
    "ext-SimpleXML": "*"
}
```

But since not all methods are used by every project, all those requirements are not stated there. This might trigger some error messages in testing. See chapter [Troubleshooting](#troubleshooting) for more.

Configuration
-------------

[](#configuration)

### Class Constants

[](#class-constants)

- The `::$LOCALE[]` array contains configuration for locale date/time formats. Example for Czech language:

```
Tools::LOCALE['cs'] => [
    'date format' => 'j. F',
    'full date format' => 'j. F Y',
    'time format' => 'H:i:s',
    'weekdays' => [
        'Sunday' => 'neděle',
        'Monday' => 'pondělí',
        'Tuesday' => 'úterý',
        'Wednesday' => 'středa',
        'Thursday' => 'čtvrtek',
        'Friday' => 'pátek',
        'Saturday' => 'sobota'
    ],
    'months' => [
        'January' => 'leden',
        'February' => 'únor',
        'March' => 'březen',
        'April' => 'duben',
        'May' => 'květen',
        'June' => 'červen',
        'July' => 'červenec',
        'August' => 'srpen',
        'September' => 'září',
        'October' => 'říjen',
        'November' => 'listopad',
        'December' => 'prosinec'
    ],
    'time ago' => [
        'y' => ['rok', 'roky', 'let'], //enclination for "1 year" form, "2-4 years" form, and "5+ years" form
        'm' => ['měsíc', 'měsíce', 'měsíců'],
        'd' => ['den', 'dny', 'dnů'],
        'h' => ['hodina', 'hodiny', 'hodin'],
        'i' => ['minuta', 'minuty', 'minut'],
        's' => ['vteřina', 'vteřiny', 'vteřin'],
        'ago' => 'zpátky',
        'in' => 'za',
        'moment' => 'okamžik'
    ]
];
```

- The `::$MESSAGE_ICONS` array contains (HTML-coded) icons that accompany each type of message. The keys (and the message types) are: `success`, `danger`, `warning` and `info`.
- The `::$PASSWORD_CHARS` constant is a string containing characters from which to generate passwords. Used by `randomPassword()`.

Testing
-------

[](#testing)

Testing is implemented using `phpunit` in projects folder `vendor/phpunit/phpunit`. The testing class is in `test/ToolsTest.php` (methods there are tested in alphabetical order). If you add a new method, don't forget to add its testing to `ToolsTest.php` and run:

```
vendor/bin/phpunit
# OR
XDEBUG_MODE=off vendor/bin/phpunit
```

- Note: The `redir()` method (which performs HTTP redirection) is not included in unit testing.
- Note: PHP included in ubuntu-latest (for GitHub Actions) does not support iconv //TRANSLIT flag as iconv implementation is unknown, therefore PHPUnit group iconvtranslit is excluded

### Troubleshooting

[](#troubleshooting)

After running `phpunit` you might get error messages saying that certain PHP extension is not available. (See chapter *PHP Extensions* for more). If your project does not require said extension(s), it will run without error messages of this kind. If it does, it's up to You to provide enabling of this/these extension(s).

Methods
-------

[](#methods)

Variable testing and setting

- `anyset()` – is any of given variables set?
- `equal()` – comparison with `isset()`
- `ifempty()` – `empty()` with `isset()`
- `ifnull()` – `isnull()` with `isset()`
- `nonempty()` – `!empty()` with `isset()`
- `nonzero()` – non-zero test with `isset()`
- `set()` – test for `isset()` or set value to a variable
- `setarray()` – shortcut for `isset()` and `is_array()`
- `setifempty()` – shortcut for if `isset()` and `empty()` then set
- `setifnotset()` – shortcut for if `!isset()` then set
- `setifnull()` – shortcut for if `isset()` and `is_null()` then set
- `setscalar()` – shortcut for `isset()` and `is_scalar()`

HTML output

- `dump()` – shortcut for `var_dump()` in ``...``
- `h()` – shortcut for `htmlspecialchars()` in UTF-8
- `htmlInput()` – output `` of given type
- `htmlOption()` – output ``
- `htmlRadio()` – output ``
- `htmlSelect()` – output `` with given options
- `htmlTextarea()` – output ``
- `htmlTextInput()` – output ``
- `stripAttributes()` – strip attributes off a HTML code

HTTP

- `curlCall()` – call a URL, return result
- `httpResponse()` – HTTP response split into headers and body
- `redir()` – make an HTTP redirection
- `urlChange()` – add/delete/modify GET variables of a URL

Messages

- `addMessage()` – add a message to a session
- `outputMessage()` – output a message
- `resolve()` – add either a 'success' or 'error' message based on a result
- `showMessages()` – show messages from session

Strings

- `begins()` – does a string begin with given parameter?
- `cutTill()` – cut string to first occurence of given parameter
- `ends()` – does a string end with given parameter?
- `exploded()` – `explode()` and return item of given index
- `mb_lcfirst()` – lower case first character (multi-byte version)
- `mb_ucfirst()` – upper case first character (multi-byte version)
- `randomPassword()` – return random password
- `str_after()` – return a part of a string after occurence of a parameter
- `str_before()` – return a part of a string before occurence of a parameter
- `str_delete()` – delete part of a byref variable
- `str_putcsv()` – inverse to `str_getcsv()`

Conversion

- `columnName()` – convert number to 26-base (alphabetical) system
- `escapeDbIdentifier()` – escape function for MySQL/MariaDb identifiers
- `escapeIn()` – escape values in SQL's `IN()` clause
- `escapeJS()` – escape for JavaScript
- `escapeSQL()` – basic escape for SQL (OBSOLETE)
- `shortify()` – limit long string to given length, add optional ellipsis
- `webalize()` – covert to URL-friendly string
- `xorCipher()` – basic ciphering
- `xorDecipher()` – basic deciphering

Variables

- `among()` – is given value among listed values
- `blacklist()` – set value to given default if on blacklist
- `whitelist()` – set value to given default if not on whitelist

Arrays

- `array_search_i()` – case-insensitive `array_search()`
- `arrayConfineKeys()` – extract and return selected keys of given array
- `arrayKeyAsValues()` – refill array's values by its keys
- `arrayListed()` – output list of array's items
- `arrayReindex()` – reindex array of arrays by given index
- `arrayRemoveItems()` – remove items from an array
- `arraySearchAssoc()` – search array for given key:value pair(s)
- `in_array_i()` – case-insensitive `in_array()`

Locale

- `localeDate()` – output date using ::`$LOCALE[]` settings
- `localeTime()` – output time using ::`$LOCALE[]` settings
- `plural()` – output appropriate singular/plural version of given word
- `relativeTime()` – output relative from `now()` using ::`$LOCALE[]` settings

Specific

- `GoogleAuthenticatorCode()` – GoogleAuthenticator hash
- `preg_max()` – return regular expression mask to match integer range from 0 to given maximum

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance80

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 64.8% 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 ~216 days

Recently: every ~649 days

Total

17

Last Release

107d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.3

v0.2.5PHP ^5.6 || ^7.0

v0.4.0PHP &gt;=7.2 &lt;8.6

### Community

Maintainers

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

---

Top Contributors

[![crs2](https://avatars.githubusercontent.com/u/9055279?v=4)](https://github.com/crs2 "crs2 (107 commits)")[![GodsDev](https://avatars.githubusercontent.com/u/2787653?v=4)](https://github.com/GodsDev "GodsDev (31 commits)")[![WorkOfStan](https://avatars.githubusercontent.com/u/26247074?v=4)](https://github.com/WorkOfStan "WorkOfStan (26 commits)")[![DowayneB](https://avatars.githubusercontent.com/u/17458467?v=4)](https://github.com/DowayneB "DowayneB (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/godsdev-tools/health.svg)

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

###  Alternatives

[greenter/greenter

Facturacion Electrónica SUNAT en Perú

33832.8k1](/packages/greenter-greenter)[pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

2116.9k](/packages/pastuhov-yii2-yml-catalog)[mozammil/putio-php

PHP SDK for put.io

101.1k](/packages/mozammil-putio-php)

PHPackages © 2026

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