Skip to content

Commit

Permalink
Merge 8cbca09 into 1e30f75
Browse files Browse the repository at this point in the history
  • Loading branch information
chadicus committed Mar 6, 2018
2 parents 1e30f75 + 8cbca09 commit ada307f
Show file tree
Hide file tree
Showing 40 changed files with 744 additions and 3,354 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
@@ -1,4 +1,3 @@
service_name: travis-ci
src_dir: .
coverage_clover: clover.xml
json_path: coveralls-upload.json
13 changes: 13 additions & 0 deletions .gitattributes
@@ -0,0 +1,13 @@
# Enforce Unix newlines
* text=lf

# Exclude unused files
# see: https://redd.it/2jzp6k
/tests export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.*.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1 @@
* @traderinteractive/opensource
24 changes: 24 additions & 0 deletions .github/CONTRIBUTING.md
@@ -0,0 +1,24 @@
# Contribution Guidelines
We welcome you to report [issues](/../../issues) or submit [pull requests](/../../pulls). While the below guidelines are necessary to get code merged, you can
submit pull requests that do not adhere to them and we will try to take care of them in our spare time. We are a smallish group of developers,
though, so if you can make sure the build is passing 100%, that would be very useful.

We recommend including details of your particular usecase(s) with any issues or pull requests. We love to hear how our libraries are being used
and we can get things merged in quicker when we understand its expected usage.

## Pull Requests
Code changes should be sent through [GitHub Pull Requests](/../../pulls). Before submitting the pull request, make sure that phpunit reports success
by running:
```sh
./vendor/bin/phpunit
```
And there are not coding standard violations by running
```sh
./vendor/bin/phpcs
```

## Builds
Our [Travis build](https://travis-ci.org/traderinteractive/filter-php) executes [PHPUnit](http://www.phpunit.de) and uses [Coveralls](https://coveralls.io/) to enforce code coverage.
While the build does not strictly enforce 100% code coverage, it will not allow coverage to drop below its current percentage.
[Scrutinizer](https://scrutinizer-ci.com/) is used to ensure code quality and enforce the [coding standard](http://www.php-fig.org/psr/psr-2/).

6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,6 @@
## Expected Behavior

## Actual Behavior

## Steps to reproduce the behavior

9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,9 @@
Fixes # .

#### What does this PR do?

#### Checklist
- [ ] Pull request contains a clear definition of changes
- [ ] Tests (either unit, integration, or acceptance) written and passing
- [ ] Relevant documentation produced and/or updated

2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
/coverage/
/vendor/
/clover.xml
phpunit.xml
composer.lock
3 changes: 0 additions & 3 deletions .scrutinizer.yml
@@ -1,7 +1,6 @@
filter:
excluded_paths:
- 'vendor/*'
- 'tests/*'
before_commands:
- 'composer install'
tools:
Expand All @@ -14,12 +13,10 @@ tools:
php_loc:
excluded_dirs:
- vendor
- tests
php_pdepend: true
php_sim: true
build_failure_conditions:
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse allowed (useful for legacy code)
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
- 'issues.label("coding-style").new.count > 5' # More than 5 new coding style issues.
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric("scrutinizer.quality", < 6)' # Code Quality Rating drops below 6
19 changes: 12 additions & 7 deletions .travis.yml
@@ -1,13 +1,18 @@
sudo: false
language: php
php:
- 5.6
- 7
- hhvm
install: composer install
script: ./vendor/bin/phpunit --coverage-clover clover.xml
after_success: sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then ./vendor/bin/coveralls -v; fi'
- 7.0
- 7.1
- 7.2
- nightly
env:
- PREFER_LOWEST="--prefer-lowest --prefer-stable"
- PREFER_LOWEST=""
matrix:
fast_finish: true
allow_failures:
- php: hhvm
- php: nightly
before_script:
- composer update $PREFER_LOWEST
script: ./vendor/bin/phpunit --coverage-clover clover.xml
after_success: ./vendor/bin/coveralls -v
15 changes: 0 additions & 15 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 Dominion Enterprises
Copyright (c) 2017 Trader Interactive

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
58 changes: 27 additions & 31 deletions README.md
@@ -1,13 +1,13 @@
#filter-php
A filtering implementation for verifying correct data and performing typical modifications to data.

[![Build Status](http://img.shields.io/travis/dominionenterprises/filter-php.svg?style=flat)](https://travis-ci.org/dominionenterprises/filter-php)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/dominionenterprises/filter-php.svg?style=flat)](https://scrutinizer-ci.com/g/dominionenterprises/filter-php/)
[![Code Coverage](http://img.shields.io/coveralls/dominionenterprises/filter-php.svg?style=flat)](https://coveralls.io/r/dominionenterprises/filter-php)
[![Build Status](http://img.shields.io/travis/traderinteractive/filter-php.svg?style=flat)](https://travis-ci.org/traderinteractive/filter-php)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/traderinteractive/filter-php.svg?style=flat)](https://scrutinizer-ci.com/g/traderinteractive/filter-php/)
[![Code Coverage](http://img.shields.io/coveralls/traderinteractive/filter-php.svg?style=flat)](https://coveralls.io/r/traderinteractive/filter-php)

[![Latest Stable Version](http://img.shields.io/packagist/v/dominionenterprises/filter.svg?style=flat)](https://packagist.org/packages/dominionenterprises/filter)
[![Total Downloads](http://img.shields.io/packagist/dt/dominionenterprises/filter.svg?style=flat)](https://packagist.org/packages/dominionenterprises/filter)
[![License](http://img.shields.io/packagist/l/dominionenterprises/filter.svg?style=flat)](https://packagist.org/packages/dominionenterprises/filter)
[![Latest Stable Version](http://img.shields.io/packagist/v/traderinteractive/filter.svg?style=flat)](https://packagist.org/packages/traderinteractive/filter)
[![Total Downloads](http://img.shields.io/packagist/dt/traderinteractive/filter.svg?style=flat)](https://packagist.org/packages/traderinteractive/filter)
[![License](http://img.shields.io/packagist/l/traderinteractive/filter.svg?style=flat)](https://packagist.org/packages/traderinteractive/filter)

##Features
* Compact, readable specification
Expand All @@ -34,7 +34,7 @@ $appendFilter = new AppendFilter();

$trimFunc = function($val) { return trim($val); };

list($status, $result, $error, $unknowns) = DominionEnterprises\Filterer::filter(
list($status, $result, $error, $unknowns) = TraderInteractive\Filterer::filter(
[
'field one' => [[$trimFunc], ['substr', 0, 3], [[$appendFilter, 'filter'], 'boo']],
'field two' => ['required' => true, ['floatval']],
Expand Down Expand Up @@ -68,14 +68,10 @@ array(0) {

##Composer
To add the library as a local, per-project dependency use [Composer](http://getcomposer.org)! Simply add a dependency on
`dominionenterprises/filter` to your project's `composer.json` file such as:
`traderinteractive/filter` to your project's `composer.json` file such as:

```json
{
"require": {
"dominionenterprises/filter": "~1.0"
}
}
```sh
composer require traderinteractive/filter
```

##Documentation
Expand Down Expand Up @@ -117,7 +113,7 @@ Aliased in the filterer as `in`, this filter is a wrapper around `in_array` incl

The following does a strict check for `$value` against the 3 accepted values.
```php
\DominionEnterprises\Filter\Arrays::in($value, ['a', 'b', 'c']);
\TraderInteractive\Filter\Arrays::in($value, ['a', 'b', 'c']);
```

#### Arrays::filter
Expand All @@ -126,7 +122,7 @@ default bounds are 1+, so an empty array fails by default.

The following checks that the `$value` is an array with exactly 3 elements.
```php
\DominionEnterprises\Filter\Arrays::filter($value, 3, 3);
\TraderInteractive\Filter\Arrays::filter($value, 3, 3);
```

#### Arrays::ofScalars
Expand All @@ -135,7 +131,7 @@ given filters (given in the same format as used by `Filterer::filter`.

The following checks that `$value` is an array of unsigned integers.
```php
$value = \DominionEnterprises\Filter\Arrays::ofScalars($value, [['uint']]);
$value = \TraderInteractive\Filter\Arrays::ofScalars($value, [['uint']]);
```

#### Arrays::ofArrays
Expand All @@ -145,7 +141,7 @@ filters (given in the same format as used by `Filterer::filter`.
The following checks that `$value` is an array of items that each have an `id` key with a numeric value. No other keys would be allowed. For
example, the following is valid input: `[['id' => '1'], ['id' => '2']]`.
```php
$value = \DominionEnterprises\Filter\Arrays::ofArrays($value, ['id' => [['uint']]]);
$value = \TraderInteractive\Filter\Arrays::ofArrays($value, ['id' => [['uint']]]);
```

#### Arrays::ofArray
Expand All @@ -156,7 +152,7 @@ essentially a flipped version of `Filterer::filter` that allows for testing nest
Aliased in the filterer as `flatten`, this filter flattens a multi-dimensional array to a single dimension. The order of values will be
maintained, but the keys themselves will not. For example:
```php
$value = \DominionEnterprises\Filter\Arrays::flatten([[1, 2], [3, [4, 5]]]);
$value = \TraderInteractive\Filter\Arrays::flatten([[1, 2], [3, [4, 5]]]);
assert($value === [1, 2, 3, 4, 5]);
```

Expand All @@ -167,15 +163,15 @@ are lists of strings for true values and false values. By default, the strings

The following example converts `$value` to a boolean allowing the strings "on" and "of".
```php
$enabled = \DominionEnterprises\Filter\Booleans::filter($value, false, ['on'], ['off']);
$enabled = \TraderInteractive\Filter\Booleans::filter($value, false, ['on'], ['off']);
```
#### Booleans::convert
Aliased in the filterer as `bool-convert`, this filter will convert a given boolean value into the provided true or false conditions. By default the
return values are the strings 'true' and 'false'

The following converts the boolean `$value` to either 'yes' or 'no'
```php
$answer = \DominionEnterprises\Filter\Booleans::convert($value, 'yes', 'no');
$answer = \TraderInteractive\Filter\Booleans::convert($value, 'yes', 'no');
```

#### Floats/Ints/UnsignedInt::filter
Expand All @@ -191,7 +187,7 @@ validation.

The following checks that `$value` is an integer between 1 and 100 inclusive, and returns the integer (after casting it if it was a string).
```php
$value = \DominionEnterprises\Filter\UnsignedInt::filter($value, false, 1, 100);
$value = \TraderInteractive\Filter\UnsignedInt::filter($value, false, 1, 100);
```

#### Strings::filter
Expand All @@ -201,14 +197,14 @@ string. The default bounds are 1+, so an empty string fails by default.

The following checks that `$value` is a non-empty string.
```php
\DominionEnterprises\Filter\Strings::filter($value);
\TraderInteractive\Filter\Strings::filter($value);
```

#### Strings::explode
Aliased in the filterer as `explode`, this filter is essentially a wrapper around the built-in [`explode`](http://www.php.net/explode) method
with the value first in order to work with the `Filterer`. It also defaults to using `,` as a delimiter. For example:
```php
$value = \DominionEnterprises\Filter\Strings::explode('abc,def,ghi');
$value = \TraderInteractive\Filter\Strings::explode('abc,def,ghi');
assert($value === ['abc', 'def', 'ghi']);
```

Expand All @@ -219,46 +215,46 @@ null values through without an error (they will stay null and not get converted

The following checks that `$value` is a URL.
```php
\DominionEnterprises\Filter\Url::filter($value);
\TraderInteractive\Filter\Url::filter($value);
```

#### Email::filter
Aliased in the filterer as `email`, this filter verifies that the argument is an email.

The following checks that `$value` is an email.
```php
\DominionEnterprises\Filter\Email::filter($value);
\TraderInteractive\Filter\Email::filter($value);
```

#### DateTime::filter
Aliased in the filterer as `date`, this will filter the value as a `\DateTime` object. The value can be any string that conforms to [PHP's valid date/time formats](http://php.net/manual/en/datetime.formats.php)

The following checks that `$value` is a date/time.
```php
$dateTime = \DominionEnterprises\Filter\DateTime::filter('2014-02-04T11:55:00-0500');
$dateTime = \TraderInteractive\Filter\DateTime::filter('2014-02-04T11:55:00-0500');
```

#### DateTime::format
Aliased in the filterer as `date-format`, this will filter a given `\DateTime' value to a string based on the given format.

The following returns formatted string for a given `\DateTime` `$value`
```php
$formatted = \DominionEnterprises\Filter\DateTime::format($value, 'Y-m-d H:i:s');
$formatted = \TraderInteractive\Filter\DateTime::format($value, 'Y-m-d H:i:s');
```

#### DateTimeZone::filter
Aliased in the filterer as `date`, this will filter the value as a `\DateTimeZone` object. The value can be any [supported timezone name](http://php.net/manual/en/timezones.php)

The following checks that `$value` is a timezone
```php
$timezone = \DominionEnterprises\Filter\DateTimeZone::filter('America/New_York');
$timezone = \TraderInteractive\Filter\DateTimeZone::filter('America/New_York');
```

##Contact
Developers may be contacted at:

* [Pull Requests](https://github.com/dominionenterprises/filter-php/pulls)
* [Issues](https://github.com/dominionenterprises/filter-php/issues)
* [Pull Requests](https://github.com/traderinteractive/filter-php/pulls)
* [Issues](https://github.com/traderinteractive/filter-php/issues)

##Project Build
With a checkout of the code get [Composer](http://getcomposer.org) in your PATH and run:
Expand Down
41 changes: 0 additions & 41 deletions build.php

This file was deleted.

0 comments on commit ada307f

Please sign in to comment.