Download the PHP package iansltx/business-days without Composer

On this page you can find all versions of the php package iansltx/business-days. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package business-days

BusinessDays

Author Latest Version Build Status HHVM Status Coverage Status Quality Score Code Climate SensioLabs Insight Total Downloads

BusinessDays is a set of tools for dealing with date calculations when certain (non-business/holiday) days don't count.

This package contains two calculators, FastForwarder and Rewinder, plus a set of filters that can be used with them.

FastForwarder is configured with a day count (N) and a set of callbacks defining what isn't a business day, Once configured, provide it with a start date and it'll return a date that is the first business day at least N business days in the future. Rewinder does the same thing, except working in the opposite temporal direction.

The start date passed into the calculators can be a DateTime or DateTimeImmutable, or a subclass thereof. The value returned will be a clone of whatever was passed in, with its timestamp updated.

This library should conform to PSRs 1, 2 and 4, and requires PHP 5.5 or newer (5.6 recommended). 5.6 is the oldest version of the runtime that has automated tests running.

Install

Via Composer

If you don't want Composer, you may download the source zipball directly from GitHub and load it using a PSR-4 compliant autoloader. If you don't have such an autoloader, require autoload.php to get one that works for this library.

Usage

Filters

Calculators (FastForwarder and Rewinder) evaluate filter functions/methods/closures to see whether a given date should be classified as a business day or not. You can provide a closure directly, or use one of the convenience methods to compose a filter more quickly.

The convenience methods simply wrap either functions from StaticFilter or create closures via FilterFactory. Either of these filter utility classes may be used standalone to filter DateTime objects. Additionally, these two filter classes provide more filters than are exposed via the convenience methods on FastForwarder/Rewinder, so check them before rebuilding a filter definition from scratch.

Note that filters requiring numeric input have internal checks that require an explicit int cast for all parameters. Also, while skipWhen filters are executed on-add to check argument and return types, non-closure arguments are allowed, so you can use object methods, utility functions or global functions can be used as filters in addition to closures.

Let's set up a FastForwarder, add some filters, and do some calculations...

NOTE: Fractional days are rounded up to the next whole day amount; e.g. 2.5 days will be treated as 3.

Exporting/Importing Filter Sets

The list of filters associated with a given calculator may be dumped as an array via getSkipWhenFilters(). This array can be set as filter storage for another calculation class when that class is created, so a set of filters only needs to be defined once.

Some notes on this functionality:

  1. Any filters added after construction won't propagate to the calculation object that you got the original filter set from.
  2. Passing in a set of filters at construction time will not run argument and return type tests on filters contained therein.

With that, let's copy our filters to a new Rewinder, which as its name suggests goes in the opposite direction, and calculate a few more dates.

For More Info

For more information on filter arguments etc., take a look at the source. All methods and classes have docblocks. The callable-based syntax of skipWhen() allows for arbitrarily complex definitions of whether a date should be skipped, as can be seen in more complex filters like isEasterMonday.

Testing

humbug.json is included if you want to do mutation testing with Humbug. Currently, not all mutations are caught; PRs are welcome to help rectify this issue. composer test only runs PHPUnit tests.

Contributing

Please see CONTRIBUTING for details. Additional static filters/filter factories are welcome!

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

This library is BSD 2-clause licensed. Please see License File for more information.


All versions of business-days with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iansltx/business-days contains the following files

Loading the files please wait ....