I'm creating a PHP app targetting companies (in Congo), ultimately helping them manage the employees and their statuses.
The legal part is constructed in 3 parts, in order of priority: The labor code, The collective agreement, the rules of procedures.
The hardest part for me, yet, is to write the "conditional periods" of the law, the agreements and the in the rules of procedures. For instance, concerning the trial periods of a fixed term contract:
The law and collective agreement state:
- From 0 to 6 months, the trial period is 15 days.
- Above, the trial period is 1 month.
While the company's internal rules state:
- For categories 1 to 6, the trial period is 5 days.
- For categories 7 to 8, the trial period is 10 days.
- For categories 9 to 12, the trial period is 15 days.
In this typical example, the internal rules state something based on different conditions than the law. I'm having a hard time writing a class in which I can store a type of condition (duration or category), interval (from x
day/month/year to y
day/month/year, or from category x
to y
), the result (a duration in day/month/year).
In my v1, I had this:
'ftc_trial_periods' => [
[
'left' => 'duration',
'intervals' => [0, '6 months'],
'result' => '15 days',
],
'1 months',
];
Using strtotime to convert the date strings, which turned out to be hard to use.
I'm thinking about something like the DatePeriod
PHP class, instead of dates, I would use DateInteval
as intervals (from x
to y
) but not sure if it would be the best approach. Are there better solutions in the wild?