PHPackages                             saritasa/php-common - 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. saritasa/php-common

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

saritasa/php-common
===================

Saritasa classes, that can be universally used in any application

1.2.2(3y ago)0287.4k↓77.8%4[1 PRs](https://github.com/Saritasa/php-common/pulls)7MITPHPPHP &gt;=7.0

Since Apr 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Saritasa/php-common)[ Packagist](https://packagist.org/packages/saritasa/php-common)[ RSS](/packages/saritasa-php-common/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (7)

PHP Common classes
==================

[](#php-common-classes)

[![PHP Unit](https://github.com/Saritasa/php-common/workflows/PHP%20Unit/badge.svg)](https://github.com/Saritasa/php-common/actions)[![PHP CodeSniffer](https://github.com/Saritasa/php-common/workflows/PHP%20Codesniffer/badge.svg)](https://github.com/Saritasa/php-common/actions)[![CodeCov](https://camo.githubusercontent.com/12ae7dd61da00377133c90a0509c6450a208d0eea81d31515299e6d2b8d107b7/68747470733a2f2f636f6465636f762e696f2f67682f53617269746173612f7068702d636f6d6d6f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Saritasa/php-common)[![Release](https://camo.githubusercontent.com/6b036435006211aefa3c238db982e38136540647f93b5b870019eb4a0fb9bdc9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73617269746173612f7068702d636f6d6d6f6e2e737667)](https://github.com/Saritasa/php-common/releases)[![PHPv](https://camo.githubusercontent.com/a51a2de7870ee269d8d79020bd5163403bdedddbe359688965e6fc90e86eeaae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73617269746173612f7068702d636f6d6d6f6e2e737667)](http://www.php.net)[![Downloads](https://camo.githubusercontent.com/0e8df0b22be50c8d90dd9a6332877ac64f1eecb44d060e3d19c37ff3c5d11a6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617269746173612f7068702d636f6d6d6f6e2e737667)](https://packagist.org/packages/saritasa/php-common)

Common Saritasa classes and helpers, that can be used universally in any application. This package should not depend on any framework or library.

Usage
-----

[](#usage)

Install the `saritasa/php-common` package:

```
$ composer require saritasa/php-common
```

Available classes
-----------------

[](#available-classes)

### Enum

[](#enum)

Alternative for [SplEnum](http://php.net/manual/ru/class.splenum.php) class. Designed to be container for repeatedly used set of constants.

**Example**:

```
class Gender extends Saritasa\Enum
{
    const MALE = 'Male';
    const FEMALE = 'Female';
}
```

then somewere in code:

```
$allGenders = Gender::getConstants();
$gender = new Gender($stringValue); // Will throw UnexpectedValueException on unknown value;
function getGenderDependentValue(Gender $gender) { ... }
```

### Dto

[](#dto)

A simple DTO, that can convert associative array to strong typed class with fields and back:

```
/**
 * @property-read string $name Person full name
 * @property-read string $address Street address
 * @property-read string $city City
 * @property-read string $state State
 * @property-read string $zip Zip Code
 */
class Address extends Dto
{
    protected $name;
    protected $address;
    protected $city;
    protected $state;
    protected $zip;
}
...
$address = new Address($request->all()) // Read only Address fields from HTTP Request
$address->toArray() // Convert to assotiative array
$address->toJson()  // Serialize to JSON format
```

### RegExp

[](#regexp)

Reusable wrapper for preg\_match;

**Example**:

```
$isEmail = new RegExp('/\w+@\w+\.\w+/');
$result = $isEmail('test@it');
```

Exception Definitions
---------------------

[](#exception-definitions)

### ConfigurationException

[](#configurationexception)

Throw this, if you find erroneous configuration.

**Example**:

```
$payPalKey = config('services.paypal_key');
if (!$payPalKey) {
    throw new ConfigurationException("PayPal key is not configured");
}

```

### PagingException

[](#pagingexception)

Throw this, if you implement paging and encounter an unrecoverable problem

### PaymentException

[](#paymentexception)

Throw this, if you implement payment service or wrapper around payment service and encounter an unrecoverable problem.

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

[](#contributing)

### Requirements

[](#requirements)

This package must:

- Do not depend on any framework or library
- Do not depend on other Saritasa packages
- Do not register any providers

1. Create fork, checkout it
2. Develop locally as usual. **Code must follow [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/)** - run [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) to ensure, that code follows style guides
3. **Cover added functionality with unit tests** and run [PHPUnit](https://phpunit.de/) to make sure, that all tests pass
4. Update [README.md](README.md) to describe new or changed functionality
5. Add changes description to [CHANGES.md](CHANGES.md) file. Use [Semantic Versioning](https://semver.org/) convention to determine next version number.
6. When ready, create pull request

### Make shortcuts

[](#make-shortcuts)

If you have [GNU Make](https://www.gnu.org/software/make/) installed, you can use following shortcuts:

- `make cs` (instead of `php vendor/bin/phpcs`) - run static code analysis with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)to check code style
- `make csfix` (instead of `php vendor/bin/phpcbf`) - fix code style violations with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)automatically, where possible (ex. PSR-2 code formatting violations)
- `make test` (instead of `php vendor/bin/phpunit`) - run tests with [PHPUnit](https://phpunit.de/)
- `make install` - instead of `composer install`
- `make all` or just `make` without parameters - invokes described above **install**, **cs**, **test** tasks sequentially - project will be assembled, checked with linter and tested with one single command

Resources
---------

[](#resources)

- [Bug Tracker](http://github.com/saritasa/php-common/issues)
- [Code](http://github.com/saritasa/php-common)
- [Changes History](CHANGES.md)
- [Authors](http://github.com/saritasa/php-common/contributors)

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 69.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 ~143 days

Recently: every ~420 days

Total

15

Last Release

1363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7632cf2eb5dd552ace9d66947ed6919e19c6a2fdb5dc73b8c71e0f9886ccc83?d=identicon)[saritasa](/maintainers/saritasa)

---

Top Contributors

[![populov](https://avatars.githubusercontent.com/u/3766033?v=4)](https://github.com/populov "populov (46 commits)")[![maxermolenko](https://avatars.githubusercontent.com/u/11438109?v=4)](https://github.com/maxermolenko "maxermolenko (18 commits)")[![hollow-en](https://avatars.githubusercontent.com/u/87475798?v=4)](https://github.com/hollow-en "hollow-en (1 commits)")[![veeeeeRySeXy](https://avatars.githubusercontent.com/u/10694924?v=4)](https://github.com/veeeeeRySeXy "veeeeeRySeXy (1 commits)")

---

Tags

phpphpsaritasa

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/saritasa-php-common/health.svg)

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21623.4k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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