applicazza/appointed

Check whether required appointment slot is open or offer closest available one

Maintainers

👁 unnutz

Package info

github.com/applicazza/appointed

pkg:composer/applicazza/appointed

Statistics

Installs: 10 836

Dependents: 4

Suggesters: 0

Stars: 1

Open Issues: 1

0.6.4 2017-07-10 11:31 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 6aae48ce9a1256f6ca698ed23faab98aadf6827c

  • Artyom S <artyom.woop@applicazza.com>

This package is not auto-updated.

Last update: 2026-06-21 12:52:43 UTC


README

👁 GitHub tag
 👁 license
 👁 Packagist

Installation

composer require applicazza/appointed

Usage

  • Set up default timezone, i.e.
date_default_timezone_set('Asia/Jerusalem');
  • Instantiate business day
use Applicazza\Appointed\BusinessDay;

// ...
$business_day = new BusinessDay;
  • Create some operating periods and add them to business day. If some operating periods cannot be added then false will be returned and no changes will be applied whatsoever
use Applicazza\Appointed\Period;

// ...

$period_0900_1400 = Period::make(today( 9, 00), today(14, 00));
$period_1600_1900 = Period::make(today(16, 00), today(19, 00));

$business_day->addOperatingPeriods(
 $period_1600_1900,
 $period_0900_1400
);
  • Create some appointments and add them to business day. If some appointments cannot be added then false will be returned and no changes will be applied whatsoever
use Applicazza\Appointed\Appointment;

// ...

$appointment_1100_1130 = Appointment::make(today( 11, 00), today(11, 30));
$appointment_1200_1330 = Appointment::make(today( 12, 00), today(13, 30));

$business_day->addAppointments(
 $appointment_1100_1130,
 $appointment_1200_1330
);
  • To fit previously failed appointment use BusinessDay::fit(Appointment $appointment, $direction = 'forward') that will return either null or recommended Appointment
$business_day->fit($appointment_1300_1330, 'backward');
$business_day->fit($appointment_1300_1330);
  • To delete appointment(s) use BusinessDay::deleteAppointments(Appointment ...$appointment) that will return boolean
$business_day->deleteAppointments($appointment_1300_1330);
  • To delete operating period use BusinessDay::deleteOperatingPeriod(Period $period) that will return boolean
$business_day->deleteOperatingPeriod($period_0900_1400)
  • To edit operating period use BusinessDay::editOperatingPeriod(Period $old_period, Period $new_period) that will return boolean
$business_day->editOperatingPeriod($period_1330_1400, $period_1330_1430)
  • To get whole day agenda use BusinessDay::getAgenda() that will return array of Period and/or Appointment ordered ascending. Since underlying classes implement JsonSerializable interface this data may be easily encoded to json.
$agenda = $business_day->getAgenda();
// To pretty print results
echo json_encode($business_day->getAgenda(), JSON_PRETTY_PRINT), PHP_EOL;

Helpers

use function Applicazza\Appointed\interval;
use function Applicazza\Appointed\today;
// ...
interval($hours = 0, $minutes = 0, $seconds = 0);
today($hours = 0, $minutes = 0, $seconds = 0);