Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davispeixoto committed Jan 29, 2019
1 parent 35f71dd commit 42844e5
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 2 deletions.
69 changes: 69 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,69 @@
checks:
php:
check_method_contracts:
verify_interface_like_constraints: true
verify_documented_constraints: true
verify_parent_constraints: true
avoid_unnecessary_concatenation: true
avoid_todo_comments: true
avoid_perl_style_comments: true
avoid_multiple_statements_on_same_line: true
avoid_fixme_comments: true
align_assignments: false
classes_in_camel_caps: true
encourage_postdec_operator: true
encourage_single_quotes: true
fix_line_ending: true
function_in_camel_caps: true
line_length:
max_length: '200'
more_specific_types_in_doc_comments: true
naming_conventions:
local_variable: '^[a-z][a-zA-Z0-9]*$'
abstract_class_name: ^Abstract|Factory$
utility_class_name: 'Utils?$'
constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$'
property_name: '^[a-z][a-zA-Z0-9]*$'
method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$'
parameter_name: '^[a-z][a-zA-Z0-9]*$'
interface_name: '^[A-Z][a-zA-Z0-9]*Interface$'
type_name: '^[A-Z][a-zA-Z0-9]*$'
exception_name: '^[A-Z][a-zA-Z0-9]*Exception$'
newline_at_end_of_file: true
no_goto: true
no_long_variable_names:
maximum: '20'
no_short_method_names:
minimum: '3'
optional_parameters_at_the_end: true
overriding_parameter: true
param_doc_comment_if_not_inferrable: true
parameter_doc_comments: true
parameters_in_camelcaps: true
phpunit_assertions: true
prefer_while_loop_over_for_loop: true
properties_in_camelcaps: true
return_doc_comment_if_not_inferrable: true
return_doc_comments: true
simplify_boolean_return: true
uppercase_constants: true
use_self_instead_of_fqcn: true

filter: { }
coding_style:
php:
indentation:
general:
size: 1
build:
nodes:
analysis:
project_setup:
override: ['true']
tests:
override:
-
command: 'vendor/bin/phpunit --coverage-clover=results'
coverage:
file: 'results'
format: 'clover'
12 changes: 12 additions & 0 deletions .travis.yml
@@ -0,0 +1,12 @@
language: php

php:
- 7.1
- 7.2

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev

script:
- composer test
100 changes: 98 additions & 2 deletions README.md
@@ -1,2 +1,98 @@
# dates_for_reports
Using dates for reports based on date is a pain... Here is something to help it out
# Dates for reports

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

[![Latest Stable Version](https://img.shields.io/packagist/v/davispeixoto/dates_for_reports.svg)](https://packagist.org/packages/davispeixoto/dates_for_reports)
[![Total Downloads](https://img.shields.io/packagist/dt/davispeixoto/dates_for_reports.svg)](https://packagist.org/packages/davispeixoto/dates_for_reports)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/davispeixoto/dates_for_reports/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/davispeixoto/dates_for_reports/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/davispeixoto/dates_for_reports/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/davispeixoto/dates_for_reports/?branch=master)
[![Build Status](https://travis-ci.org/davispeixoto/dates_for_reports.svg?branch=master)](https://travis-ci.org/davispeixoto/dates_for_reports)

## Installation
The workflow package can be installed via [Composer](http://getcomposer.org) by requiring the
`davispeixoto/workflow` package in your project's `composer.json`.

```json
{
"require": {
"davispeixoto/dates_for_reports": "~1.0"
}
}
```

Or

```sh
$ php composer.phar require davispeixoto/dates_for_reports
```

And running a composer update from your terminal:
```sh
php composer.phar update
```

## Usage
To use it, first you need to create the status you are going to use
for representing your states.

```php
<?php
use DavisPeixoto\ReportDates\Dates;

$date_helper = new Dates();
$weeks = $date_helper->getWeeksBreak($from, $to);

foreach ($weeks as $week) {
$label = $week->getLabel();
$businessDaysAmount = $week->getBusinessDays();
// do something with dates here
}
```



## License
This software is licensed under the [MIT license](http://opensource.org/licenses/MIT)

## Versioning
This project follows the [Semantic Versioning](http://semver.org/)

## 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.
1. PHP Mess Detector
2. PHPStan
3. PHP Code Sniffer (we use PSR-2 style)
4. 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:

1. They are designed to test all entities and services
2. Simple getters and setters can be skipped
3. Simple constructors and destructors can be skipped
4. All business rules should be covered
5. All public methods that cannot be skipped as per above rule should be tested
6. All private methods should be covered through proper inputs into public methods
7. It is highly recommended to use data providers for passing parameters to
test methods

## Thanks
For all PHP community
54 changes: 54 additions & 0 deletions composer.json
@@ -0,0 +1,54 @@
{
"name": "davispeixoto/dates_for_reports",
"description": "A library for dealing with dates on reports",
"keywords": [
"Reporting",
"BI",
"Datetime"
],
"license": "MIT",
"authors": [
{
"name": "Davis Peixoto",
"email": "davis.peixoto@gmail.com"
}
],
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "~6.2",
"phpstan/phpstan": "~0.8",
"squizlabs/php_codesniffer": "^2.3",
"behat/behat": "~3.0",
"friendsofphp/php-cs-fixer": "^2.11",
"phpmd/phpmd": "^2.6",
"roave/security-advisories": "dev-master"
},
"autoload": {
"psr-4": {
"DavisPeixoto\\ReportDates\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"DavisPeixoto\\ReportDates\\Tests\\": "tests"
}
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse src --level=7",
"phpunit": "vendor/bin/phpunit --verbose --colors=always",
"behat": "vendor/bin/behat --colors",
"phpcs": "vendor/bin/phpcs src tests --standard=psr2 -sp --colors",
"phpcs-fixer-src": "vendor/bin/php-cs-fixer fix src",
"phpcs-fixer-tests": "vendor/bin/php-cs-fixer fix tests",
"test": [
"@phpstan",
"@phpunit",
"@behat",
"@phpcs-fixer-src",
"@phpcs-fixer-tests",
"@phpcs"
]
}
}

0 comments on commit 42844e5

Please sign in to comment.