Complex data objects containing logic and relationships.

v2.0.0 2014-07-28 01:28 UTC


Complex data objects containing logic and relationships.


All of my components require PHP >= 5.4.


Use Composer to install: composer require ts/logicobject:~2.0

What's this for?

This basically is a port from one internal implementation I did at my last job where I needed to automatically fill a database table with holidays for the next five years, because it was done by hand up to that point.

I've expanded upon the concept a bit by using my DataObject component, creating base classes which I extended and localized accordingly.

Usage is basically pretty straight-forward, just have a look at the DayCalculator class for a quick example:

use TS\LogicObject\German\Bundesland;
use TS\LogicObject\German\DayCalculator;
use TS\LogicObject\German\Feiertage;
use TS\LogicObject\German\Monat;
use TS\LogicObject\German\Tag;

// Create holiday collection
$feiertage = new Feiertage(2013);

// Create DayCalculator
$dayCalc = new DayCalculator($feiertage);

// Specify a month
$month = Monat::JANUAR();

// Total days in this month
$dayCalc->getTotal($month); // 31

// Total weekdays (monday - friday)
$dayCalc->getTotalWeekdays($month); // 23

// Total workdays (defaults to monday - friday as well, but can be changed)
$dayCalc->getTotalWorkdays($month); // 23
$dayCalc->getTotalWorkdays($month, Tag::MONTAG(), Tag::SAMSTAG()); // 27 - monday-saturday

// Workdays: Remove national holidays and if given a bundesland local holidays as well
$bundesland = Bundesland::BADEN_WUERTTEMBERG();

$dayCalc->getWorkdays($month); // 22 - New Year's fell on a tuesday and is a national holiday
$dayCalc->getWorkdays($month, $bundesland); // 22 as well - Heilige drei Könige fell on a sunday