PHPackages                             akifrabbani/molek - 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. akifrabbani/molek

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

akifrabbani/molek
=================

Calculate amount based on two dates and a ruleset

0.3(6y ago)34.6kMITPHPPHP &gt;=5.2.0

Since Jul 12Pushed 6y ago2 watchersCompare

[ Source](https://github.com/akifrabbani/molek-php)[ Packagist](https://packagist.org/packages/akifrabbani/molek)[ Docs](https://github.com/akifrabbani/molek-php)[ RSS](/packages/akifrabbani-molek/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)DependenciesVersions (5)Used By (0)

Molek
=====

[](#molek)

[![Latest Version](https://camo.githubusercontent.com/d65826a2474f1cdd8b17a587c3924dd3b665c6d3816f1ed68b6ee89b8f5b70f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616b696672616262616e692f6d6f6c656b2e7376673f7374796c653d666c61742d737175617265)](https://github.com/akifrabbani/molek/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/359b5a9758195ae2030f1a15ceaa3505f56642e40227c1620f3d4c26bc053a6b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616b696672616262616e692f6d6f6c656b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/akifrabbani/molek)[![Coverage Status](https://camo.githubusercontent.com/ff88e9256711580e82cf97e3c533732192d2c4208b02b49ef6deb2dac06ae85b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616b696672616262616e692f6d6f6c656b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/akifrabbani/molek/code-structure)[![Quality Score](https://camo.githubusercontent.com/16e304174839bb8a14e960de35e8de782a143bc220b8aeda2adc9fe9d8a3a3cc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616b696672616262616e692f6d6f6c656b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/akifrabbani/molek)[![Total Downloads](https://camo.githubusercontent.com/edbfd91d13274721ee569e30d83e249acfb5e7aa49077708b5c8349b15d0487c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f736b656c65746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/skeleton)

Payment amount calculator based on two dates and ruleset.

Install
-------

[](#install)

Via Composer

```
$ composer require akifrabbani/molek
```

Usage
-----

[](#usage)

```
$start = new DateTime("2019-07-20 08:00:00");
$end = new DateTime("2019-09-20 23:00:00");

// Rule for every hour is RM 1.
$ruleset = [
	'base_price' => 0,
	'operation_hours' => [
		'start' => '08:00',
		'end' => '20:00'
	],
	'first' => [
		[
			'type' => 'minute',
			'duration' => 15,
			'price' => 0
		],
		[
			'type' => 'hour',
			'duration' => 1,
			'price' => 4,
			'days' => ['sat', 'sun'],
			'dates' => [
				'2019-07-11'
			]
		],
		[
			'type' => 'hour',
			'duration' => 1,
			'price' => 2,
			'days' => ['mon', 'tue', 'wed', 'thu', 'fri']
		]	],
	'normal' => [
		[
			'type' => 'hour',
			'interval' => 1,
			'price' => 1,
			'days' => ['mon', 'tue', 'wed', 'thu', 'fri']
		],
		[
			'type' => 'hour',
			'interval' => 1,
			'price' => 1.5,
			'days' => ['sat', 'sun'],
			'dates' => [
				'2019-07-11'
			]
		]
	],
	'max' => [
		[
			'type' => 'hour',
			'duration' => 8,
			'price' => 10,
			'days' => ['mon', 'tue', 'wed', 'thu', 'fri']
		],
		[
			'type' => 'hour',
			'duration' => 8,
			'price' => 15,
			'days' => ['sat', 'sun'],
			'dates' => [
				'2019-07-11'
			]
		]
	]
];

$molek = new AkifRabbani\Molek\Molek($ruleset);
echo "Price is RM " . $molek->calculate($start, $end);
```

Credits
-------

[](#credits)

- Akif Rabbani ()
- Mohd Hafizuddin M Marzuki ()

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~1 days

Total

3

Last Release

2542d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1407235?v=4)[Akif Rabbani](/maintainers/akifrabbani)[@akifrabbani](https://github.com/akifrabbani)

---

Top Contributors

[![akifrabbani](https://avatars.githubusercontent.com/u/1407235?v=4)](https://github.com/akifrabbani "akifrabbani (10 commits)")[![apih](https://avatars.githubusercontent.com/u/798269?v=4)](https://github.com/apih "apih (4 commits)")

---

Tags

datecalculatemolek

### Embed Badge

![Health badge](/badges/akifrabbani-molek/health.svg)

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

###  Alternatives

[rlanvin/php-rrule

Lightweight and fast recurrence rules for PHP (RFC 5545)

70011.4M54](/packages/rlanvin-php-rrule)[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6239.3M51](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.7M22](/packages/league-period)[morilog/jalali

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in PHP applications, based on Jalali (Shamsi) DateTime class.

9231.2M49](/packages/morilog-jalali)[brick/date-time

Date and time library

3623.6M94](/packages/brick-date-time)[aeon-php/calendar

PHP type safe, immutable calendar library

20410.2M16](/packages/aeon-php-calendar)

PHPackages © 2026

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