davispeixoto / dates_for_reports
A library for dealing with dates on reports
Requires
- php: >=7.1
- myclabs/php-enum: 1.*
Requires (Dev)
- behat/behat: ~3.0
- friendsofphp/php-cs-fixer: ^2.11
- phpmd/phpmd: ^2.6
- phpstan/phpstan: ~0.8
- phpunit/phpunit: ~6.2
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-11-05 07:28:39 UTC
README
This is a library with a few dates helpers for using at reports. Mainly getting an array of dates to use for querying and/or displaying
Installation
This package can be installed via Composer by requiring the
davispeixoto/dates_for_reports
package in your project's composer.json
.
{ "require": { "davispeixoto/dates_for_reports": "~1.0" } }
Or
$ php composer.phar require davispeixoto/dates_for_reports
And running a composer update from your terminal:
php composer.phar update
Usage
Here is a common usage example.
<?php use DavisPeixoto\ReportDates\Dates; $date_helper = new Dates(); $weeks = $date_helper->getWeeksBreak($from, $to); foreach ($weeks as $week) { $businessDaysAmount = $week->getBusinessDays(); // do something with dates here }
Please find out more about usage and use cases.
License
This software is licensed under the MIT license
Versioning
This project follows the Semantic Versioning
Contributing and Quality standards and tests
This package strive to have the best as of now to ensure its quality. We count on unit tests, behavior tests and static analysis tools.
Static tools
Several static analysis tools are used to ensure a good design and architecture.
- PHP Mess Detector
- PHPStan
- PHP Code Sniffer (we use PSR-2 style)
- PHP Code Sniffer Fixer
The first two gives some metric of cyclomatic complexity and naming conventions. The last two are the basic for ensure we have the proper code style (PSR-2).
We also can count on PHPStorm/IDE related inspections.
BDD
The directory features has all .feature files, written in Gherkin. The subdirectory bootstrap contains the BDD-implementation of Behat classes.
We do not create CRUD features, but all business rules should be written here, through examples.
Unit Tests
The tests directory has the unit tests, written in phpunit 6+, and strive to follow the rules:
- They are designed to test all entities and services
- Simple getters and setters can be skipped
- Simple constructors and destructors can be skipped
- All business rules should be covered
- All public methods that cannot be skipped as per above rule should be tested
- All private methods should be covered through proper inputs into public methods
- It is highly recommended to use data providers for passing parameters to test methods
Thanks
For all PHP community