1. Go to this page and download the library: Download maba/clock library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maba / clock example snippets
$resolver = new ConditionalValueResolver(
new ConditionPriorityResolver(),
new CurrentTimeConditionChecker(new RealTimeClock(), new TimeConditionChecker())
);
// order of the items in the array does not matter, as they're ordered by priorities
$resolver->resolveValue(array(
// default price 20 EUR
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())
)->setValue('20 EUR'),
// from 16:00 price is 30 EUR
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setFromTime(16 * 3600)
)->setValue('30 EUR'),
// 17:00 - 18:00 we have a happy hour
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setFromTime(17 * 3600)->setUntilTime(18 * 3600)
)->setValue('15 EUR'),
// 23:00 - 03:00 price is bigger
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setFromTime(23 * 3600)->setUntilTime(03 * 3600)
)->setValue('40 EUR'),
// price is 50 EUR on Sundays. This wins over all above rules
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setWeekday(0)
)->setValue('50 EUR'),
// this overwrites price from 20:00 until 00:00
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setWeekday(0)->setFromTime(20 * 3600)
)->setValue('30 EUR'),
// first day on every month - cheap one. Wins over all above
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setDay(1)
)->setValue('10 EUR'),
// day of New Year is special
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setDay(1)->setMonth(1)
)->setValue('100 EUR'),
// Easter etc.
(new ConditionalValue())->setTimeCondition(
(new TimeCondition())->setDay(5)->setMonth(4)->setYear(2015)
)->setValue('50 EUR'),
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.