Simple helper class for accessing the days of the week as strings in PHP.
Note from the developer:
This package is literally only one class. I will likely never update this package again. I just wanted to make a simple helper class for switching between days as names and as abbreviations in a separate project. If you have any suggestions for features or ideas, feel free to fork!
Thanks,
Garrett
You can install the package via composer:
composer require gtmassey/days
To use, you can either create a new days object with the new
keyword, or you can use the make
static method, or you can call the day of week directly as a static method:
use Gtmassey\Days\Days;
$monday = new Days('Monday');
$tuesday = Days::make('Tuesday');
$wednesday = Days::Wednesday();
Once you have a Days
object, you can call the various methods to return the day of the week as a specific English formatted string:
$monday->asCharacterCode(); //'M'
$monday->asShortName(); //'Mon'
$sunday->asCharacterCode(); //'U'
$thursday->asFullName(); //'Thursday'
The character codes use R
for Thursday to avoid confusion with Tuesday and U
for Sunday to avoid confusion with Saturday.
To run the testsuite, run the following command:
composer test
The MIT License (MIT). Please see License File for more information.