PHP Classes

PHP Work from Home Schedule: Propose a schedule to work from home or the office

Recommend this page to a friend!
  Info   View files Documentation   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 62 This week: 1All time: 10,413 This week: 560Up
Version License PHP version Categories
work-home-schedule 1.0MIT/X Consortium ...5PHP 5, Time and Date, Project Management
Description 

Author

This package can propose a schedule to work from home or the office.

It considers two teams that can work from home or the office on alternate days.

The package can generate work schedules for both teams and output the schedules as files in CSV format.

Innovation Award
PHP Programming Innovation award nominee
March 2023
Number 8
Many developers have worked from home for years because they feel it is a more comfortable workplace.

Still, many companies prefer that employees work from their offices.

Since the pandemic, this preference has changed because many people have realized it is safer and faster to work from home, and employees can work more productively.

This package provides a solution to suggest a schedule to define how two teams will alternate the work location between home and office space.

Manuel Lemos
Picture of Chun-Sheng, Li
  Performance   Level  
Name: Chun-Sheng, Li <contact>
Classes: 27 packages by
Country: Taiwan Taiwan
Age: 30
All time rank: 22646 in Taiwan Taiwan
Week rank: 411 Up2 in Taiwan Taiwan Up
Innovation award
Innovation award
Nominee: 13x

Winner: 1x

Documentation

Working Home Schedule

CI Coverage Status StyleCI

Installation

  • Download `composer` firstly:
curl -sS https://getcomposer.org/installer | php

  • Install `lee/work-home-schedule` secondly:
php composer.phar require lee/work-home-schedule:^1

Introduction

This is about working home schedule to estimate current working status on specific date.

It's based on following scenario for A/B team work:

  • A team work from office today, and B team will work from home today.
  • A team work from home tomorrow, and B team will work from office tomorrow.
  • And so on.

This situation will skip on country holiday and weekend.

Usage

This class depends on Carbon::mixin method.

The code snippets are as follows:

  • Set `startDateStatus` about working from home or office.
  • Set `csvPath` about specific CSV file path.
  • Set `csvHead` about whether CSV file path has head.
  • Loading calendar data, the calendar CSV format is available here.

We assume that the 2020-04-06 is start date and working statuses are as follows:

  • The start date status is `office`.

Get next working date about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDate = $currentDate->nextWorkingDate();

$carbonDate = $nextWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$nextWorkingDate['date']; // 2020-04-07 00:00:00
$workingStatus = $nextWorkingDate['status']; // home

Get previous working date about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDate = $currentDate->previousWorkingDate();

$carbonDate = $previousWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$previousWorkingDate['date']; // 2020-04-01 00:00:00
$workingStatus = $previousWorkingDate['status']; // home

Get next working dates with specific date ranges about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDates = $currentDate->nextWorkingDates(); // The array length is 2

$nextWorkingDates[0]['date'] // Carbon::class instance
(string)$nextWorkingDates[0]['date'] // 2020-04-07 00:00:00
$nextWorkingDates[0]['status'] // home

$nextWorkingDates[1]['date'] // Carbon::class instance
(string)$nextWorkingDates[1]['date'] // 2020-04-08 00:00:00
$nextWorkingDates[1]['status'] // office

Get previous working dates with date ranges about code snippets are as follows:

require __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDates = $currentDate->previousWorkingDates(); // array length is 2

$previousWorkingDates[0]['date'] // Carbon::class instance
(string)$previousWorkingDates[0]['date'] // 2020-04-01 00:00:00
$previousWorkingDates[0]['status'] // home

$previousWorkingDates[1]['date'] // Carbon::class instance
(string)$previousWorkingDates[1]['date'] // 2020-03-31 00:00:00
$previousWorkingDates[1]['status'] // office

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (4 files)
Files folder imagetests (1 file, 1 directory)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file CannotFindDateOnCalendarException.php Class Class source
  Plain text file InvalidCsvRecordException.php Class Class source
  Plain text file InvalidStartDateStatusException.php Class Class source
  Plain text file WorkHomeSchedule.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagefixtures (4 files)
  Plain text file WorkHomeScheduleTest.php Class Class source

  Files folder image Files  /  tests  /  fixtures  
File Role Description
  Accessible without login Plain text file 2020_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_calendar.csv Data Auxiliary data
  Accessible without login Plain text file invalid_holiday_calendar.csv Data Auxiliary data
  Accessible without login Plain text file not_enough_calendar.csv Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:1
All time:10,413
This week:560Up