PHPackages                             velliz/timetables - 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. velliz/timetables

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

velliz/timetables
=================

Timetable algorithm implemented with 2 dimensional cartesius diagram

0.1.0(7y ago)0649MITPHP

Since Nov 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Velliz/timetables)[ Packagist](https://packagist.org/packages/velliz/timetables)[ RSS](/packages/velliz-timetables/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Timetables
==========

[](#timetables)

Timetable algorithm implemented with 2 dimensional cartesius diagram.

### Install

[](#install)

```
composer require velliz/timetables
```

### Usage

[](#usage)

**Criteria**

Instance a criteria for X and Y dimensions with provided example. You can have your customized **TimeDatum** and **RoomDatum** class with extending it to `Datum` abstraction.

```
$criteriaX = new \tests\TimeDatum();
$criteriaX->data = 5;
$criteriaX->closeData = array(4, 6);
```

```
$criteriaY = new \tests\RoomDatum();
$criteriaY->data = 93;
$criteriaY->closeData = array(92, 94);
```

`$criteriaY->data` is what exactly you want to search and `$criteriaY->closeData`is acceptable if the data not found in the XY dimensions.

**Driver**

```
$timetable = new \timetables\TimetableDriver();
```

**Dimensions**

This example create a 900 length size random **TimeDatum** with range value from 0 to 100.

```
$dimenX = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 900; $i++) {
    $data = new \tests\TimeDatum();
    $data->data = rand(0, 100);
    $timetable->addDimenX($data);
}
```

This example create a 100 length size random **RoomDatum** with range value from 0 to 100.

```
$dimenY = new timetables\cartesius\Dimensions();
for ($i = 0; $i < 500; $i++) {
    $data = new \tests\RoomDatum();
    $data->data = rand(0, 100);
    $timetable->addDimenY($data);
}
```

**Results**

Algorithm will find a match **TimeDatum** with value 5 and **RoomDatum** with value 93.

```
$result = $timetable->setCriteriaX($criteriaX)->setCriteriaY($criteriaY)->CalculateTimeTable();
```

And result from calculation:

```
array(6) {
  ["BestX"]=>
  int(893)
  ["BestY"]=>
  int(83)
  ["Criteria"]=>
  array(2) {
    ["X"]=>
    int(5)
    ["Y"]=>
    int(93)
  }
  ["Result"]=>
  array(2) {
    ["X"]=>
    int(5)
    ["Y"]=>
    int(93)
  }
  ["Iteration"]=>
  int(13812)
  ["Remark"]=>
  string(5) "CLEAR"
}
```

### Calculation

[](#calculation)

To create custom comparison rules, you can implement custom classes and *extends* it to **Datum**

```
class CustomRoomDatum extends Datum
```

and implements **CalculateFits** function.

```
public function CalculateFits(Datum $comparator)
{
    //simple comparison logic
    if ($comparator->data === $this->data) {
        return Datum::EQUALS;
    } else if (in_array($this->data, $comparator->closeData)) {
        return Datum::CLOSE;
    }
    return Datum::NOT_MATCH;
}
```

- `$comparator->data` is your criteria passed from function parameter
- `$this->data` is primary usage for comparison and populated from the **Dimensions**

Then return a constant provided:

- `Datum::EQUALS` if data is match
- `Datum::CLOSE` if data close matched
- `Datum::NOT_MATCH` if data not match

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

2743d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

algorithmphp-librarytimetable

### Embed Badge

![Health badge](/badges/velliz-timetables/health.svg)

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

PHPackages © 2026

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