-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
156 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/vendor | ||
.php_cs.cache | ||
.*.cache | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
language: php | ||
|
||
dist: trusty | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# OpinHelpers | ||
|
||
[![Build Status](https://travis-ci.org/fab2s/OpinHelpers.svg?branch=master)](https://travis-ci.org/fab2s/OpinHelpers) [![Latest Stable Version](https://poser.pugx.org/fab2s/opinhelpers/v/stable)](https://packagist.org/packages/fab2s/opinhelpers) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fab2s/OpinHelpers/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/fab2s/OpinHelpers/?branch=master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) [![License](https://poser.pugx.org/fab2s/opinhelpers/license)](https://packagist.org/packages/fab2s/opinhelpers) | ||
[![Documentation Status](https://readthedocs.org/projects/opinhelpers/badge/?version=latest)](http://opinhelpers.readthedocs.io/en/latest/?badge=latest) [![Build Status](https://travis-ci.org/fab2s/OpinHelpers.svg?branch=master)](https://travis-ci.org/fab2s/OpinHelpers) [![Total Downloads](https://poser.pugx.org/fab2s/opinhelpers/downloads)](https://packagist.org/packages/fab2s/opinhelpers) [![Monthly Downloads](https://poser.pugx.org/fab2s/opinhelpers/d/monthly)](https://packagist.org/packages/fab2s/opinhelpers) [![Latest Stable Version](https://poser.pugx.org/fab2s/opinhelpers/v/stable)](https://packagist.org/packages/fab2s/opinhelpers) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fab2s/OpinHelpers/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/fab2s/OpinHelpers/?branch=master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) [![License](https://poser.pugx.org/fab2s/opinhelpers/license)](https://packagist.org/packages/fab2s/opinhelpers) | ||
|
||
OpinHelpers is a bellow "Swiss Army Knife" level set of opinionated Helper libs (hence the [opin[h]el](https://en.wikipedia.org/wiki/Opinel_knife)^^) covering some of the most annoying aspects of php programing, such as UTF8 string manipulation, arbitrary precision Mathematics or properly locking a file. | ||
`OpinHelpers` is a bellow "Swiss Army Knife" level set of opinionated Helper libs (hence the [opin[h]el](https://en.wikipedia.org/wiki/Opinel_knife)^^) covering some of the most annoying aspects of php programing, such as UTF8 string manipulation, arbitrary precision Mathematics or properly locking a file. | ||
|
||
OpinHelpers libs are opinionated in several ways and do not aim at being universal, but they should hopefully be pretty useful in many IRL cases. | ||
`OpinHelpers` libs are opinionated in several ways and do not aim at being universal, but they should hopefully be pretty useful in many IRL cases. | ||
|
||
## Installation | ||
|
||
OpinHelpers can be installed using composer : | ||
`OpinHelpers` can be installed using composer : | ||
|
||
``` | ||
composer require "fab2s/opinhelpers" | ||
``` | ||
|
||
## Requirements | ||
|
||
OpinHelpers is tested against php 5.6, 7.0, 7.1, 7.2 and hhvm. | ||
`OpinHelpers` is tested against php 5.6, 7.0, 7.1, 7.2 and 7.3. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome, do not hesitate to open issues and submit pull requests. | ||
|
||
## License | ||
|
||
SoUuid is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). | ||
`OpinHelpers` is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of OpinHelpers. | ||
* (c) Fabrice de Stefanis / https://github.com/fab2s/OpinHelpers | ||
* This source file is licensed under the MIT license which you will | ||
* find in the LICENSE file or at https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
namespace fab2s\Tests; | ||
|
||
use fab2s\OpinHelpers\Bom; | ||
|
||
/** | ||
* Class BomTest | ||
*/ | ||
class BomTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider extractData | ||
* | ||
* @param string $input | ||
* @param string|null $bom | ||
* @param string $encoding | ||
*/ | ||
public function testExtract($input, $bom, $encoding) | ||
{ | ||
$this->assertSame(Bom::extract($input), $bom, $encoding); | ||
} | ||
|
||
/** | ||
* @dataProvider dropData | ||
* | ||
* @param string $input | ||
* @param string|null $bom | ||
* @param string $encoding | ||
*/ | ||
public function testDrop($input, $bom, $encoding) | ||
{ | ||
$this->assertSame(Bom::drop($input), $bom, $encoding); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function extractData() | ||
{ | ||
$string = "I am an irrelevant string\n which content does not matter"; | ||
$result = []; | ||
|
||
foreach (Bom::getBoms() as $encoding => $bom) { | ||
$result = [ | ||
// no BOM case | ||
[ | ||
$string, | ||
null, | ||
$encoding, | ||
], | ||
]; | ||
|
||
$result[] = [ | ||
"$bom$string", | ||
$bom, | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
"$bom $string", | ||
$bom, | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
"$bom\n$string", | ||
$bom, | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
" $bom$string", | ||
null, | ||
$encoding, | ||
]; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function dropData() | ||
{ | ||
$string = "I am yet another irrelevant string\n which content does not matter"; | ||
$result = []; | ||
|
||
foreach (Bom::getBoms() as $encoding => $bom) { | ||
$result = [ | ||
// no BOM case | ||
[ | ||
$string, | ||
$string, | ||
$encoding, | ||
], | ||
]; | ||
|
||
$result[] = [ | ||
"$bom$string", | ||
$string, | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
"$bom $string", | ||
" $string", | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
"$bom\n$string", | ||
"\n$string", | ||
$encoding, | ||
]; | ||
|
||
$result[] = [ | ||
" $bom$string", | ||
" $bom$string", | ||
$encoding, | ||
]; | ||
} | ||
|
||
return $result; | ||
} | ||
} |