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

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

moitran/php-common-funcs
========================

Writing useful common function in php

v1.0.1(7y ago)131MITPHPPHP ^7.0

Since Dec 18Pushed 7y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

php-common-funs
===============

[](#php-common-funs)

Writing useful common functions in php

[![Latest Stable Version](https://camo.githubusercontent.com/8ea46cc0b2b9142b0d1d4e65edc3b3ddaab7945dc23df14e62866fea575517d6/68747470733a2f2f706f7365722e707567782e6f72672f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732f762f737461626c65)](https://packagist.org/packages/moitran/php-common-funcs)[![Latest Unstable Version](https://camo.githubusercontent.com/7d12343c6bf2df1dce5e01e739a5a11bdfa720ea1a1742a3d8396ee015fc4b10/68747470733a2f2f706f7365722e707567782e6f72672f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732f762f756e737461626c65)](https://packagist.org/packages/moitran/php-common-funcs)[![Build Status](https://camo.githubusercontent.com/1b98a4df24b377a6034dda33a573f903a2b6a996c7c58591dda96b47b5f474f9/68747470733a2f2f7472617669732d63692e6f72672f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/moitran/php-common-funcs)[![codecov](https://camo.githubusercontent.com/ada566bc4e6428d9a3a603e5f06bb3d7098590921355f1b51283c9e08a64998a/68747470733a2f2f636f6465636f762e696f2f67682f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732f6272616e63682f6d61737465722f6772617068732f62616467652e737667)](https://codecov.io/gh/moitran/php-common-funcs)[![License](https://camo.githubusercontent.com/8785e39bf9136588a60ee5839d13592f9c6b6a5c3116e42f512baf1747ffc818/68747470733a2f2f706f7365722e707567782e6f72672f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732f6c6963656e7365)](https://packagist.org/packages/moitran/php-common-funcs)[![composer.lock](https://camo.githubusercontent.com/ddd58fd7b0411c7a3ef5c97c1a26bac192fa6561243c426dbcd7e13a33e209e7/68747470733a2f2f706f7365722e707567782e6f72672f6d6f697472616e2f7068702d636f6d6d6f6e2d66756e63732f636f6d706f7365726c6f636b)](https://packagist.org/packages/moitran/php-common-funcs)

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

[](#installation)

```
$ composer require moitran/php-common-funcs
```

What does it have?
------------------

[](#what-does-it-have)

- ### Array

    [](#array)

    - **groupItemsByKeys** Group items in multidimensional array by values of list keys argument.
    - **isAssocArray** Checking array input is assoc array or not [List types of array](https://www.w3schools.com/php/php_arrays.asp).
    - **isNumericArray** Checking array input is numeric array or not [List types of array](https://www.w3schools.com/php/php_arrays.asp).
    - **convertLowerUpperCase** Convert all string values in array to lower case or upper case.
    - **sortBy** Sorting multidimensional array by list keys.
- ### DateTime

    [](#datetime)

    - **getCurrentTime** Get current time with format argument
    - **getNow** Return current Unix timestamp
    - **format** Receive an date string argument and return in the specified format.
    - **getListRangeDate** Return list dates between two dates in the specified format.
    - **getPreviousDates** Return previous date in the specified format with argument is number of previous date.
    - **getPreviousDateRange** Return list previous range dates opposite with date range argument.
    - **getTimeBetweenTwoDate** Return number of Seconds (S), Minutes (M), Hours (H) or Days (D) between two dates.
    - **getAge** Return age by date of birth.
    - **niceTime** Return nice time format.

Best practice to use (\*IMO)
----------------------------

[](#best-practice-to-use-imo)

All functions in this package have static method so that if we call functions redirect like this way. It will be so hard to write the phpunit test code.

```
use MoiTran\CommonFunctions\DateCommonFunctions;

class A {
    public function doSomeThing() {
        $time = DateCommonFunctions::getCurrentTime('Y/m/d');
        // do some thing
    }
}
```

The solution for it is using this trait [StaticCalling](https://github.com/moitran/php-common-funcs/blob/master/src/StaticCalling.php) to call those static functions. The code will be like this one

```
use MoiTran\CommonFunctions\DateCommonFunctions;
use MoiTran\CommonFunctions\StaticCalling;

class A {
    use StaticCalling;

    public function doSomeThing() {
        $time = $this->callStatic(DateCommonFunctions::class, DateCommonFunctions::GET_CURRENT_TIME_FUNC, ['Y/m/d']);
        // do some thing
    }
}
```

License
-------

[](#license)

This package is under [MIT License](https://github.com/moitran/php-common-funcs/blob/master/LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Unknown

Total

1

Last Release

2705d ago

### Community

Maintainers

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

---

Top Contributors

[![moitran](https://avatars.githubusercontent.com/u/30226535?v=4)](https://github.com/moitran "moitran (44 commits)")

---

Tags

arraycommon-functionsdate-timenicetimephp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

PHPackages © 2026

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