Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ tools:
timeout: 600
php_code_sniffer:
config:
standard: "PSR2"
standard: "PSR12"
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Write code and tests. When you are ready, run the tests.
$ composer test
```



When you are ready with the code, tested it and documented it, you can commit and push it with the following commands:

``` bash
Expand Down Expand Up @@ -76,9 +78,14 @@ $ git push -f origin feature-or-bug-fix-description

## Coding standard

This repository follows the [PSR-2 standard](http://www.php-fig.org/psr/psr-2/) and so, if you want to contribute,
This repository follows the [PSR-12 standard](https://www.php-fig.org/psr/psr-12/) and so, if you want to contribute,
you must follow these rules.

To ensure that your code meets the coding standards, you can run the linter using the following command:

```bash
$ composer lint
```

## Semver

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"type": "library",
"license": "MIT",
"require-dev": {
"phpunit/phpunit": "^4.0"
"phpunit/phpunit": "^4.0",
"squizlabs/php_codesniffer": "4.x-dev"
},
"autoload": {
"psr-4": {
Expand All @@ -25,6 +26,8 @@
]
},
"scripts": {
"lint": "phpcs src",
"lint-fix": "phpcbf src",
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit -c phpunit.xml.ci"
},
Expand Down
12 changes: 12 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset name="PHPFunct">
<description>PHPFunct ruleset</description>

<!-- Include PSR12 standard -->
<rule ref="PSR12" />

<!-- Disable line length exceeding 120 characters -->
<rule ref="Generic.Files.LineLength">
<exclude name="Generic.Files.LineLength.TooLong" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function true($value)

/**
* Returns the first param if isset or the second one or null if it doesn't
*
*
* @param mixed $value
* @param mixed $default
* @return mixed
Expand Down
3 changes: 1 addition & 2 deletions src/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function chompLeft($input, $prefix)
function chompRight($input, $suffix)
{
if (endsWith($input, $suffix)) {

return mb_substr($input, 0, mb_strlen($input) - mb_strlen($suffix));
}

Expand Down Expand Up @@ -654,7 +653,7 @@ function stripPunctuation($string)
*/
function swapCase($string, $mb = false)
{
return array_reduce(str_split($string), function($carry, $item) use ($mb) {
return array_reduce(str_split($string), function ($carry, $item) use ($mb) {
return $carry .= isLower($item, $mb) ? toUpper($item, $mb) : toLower($item, $mb);
}, '');
}
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Collection/CollectionFirstNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*/
class CollectionFirstNTest extends \PHPUnit_Framework_TestCase
{

public function testFirst()
{
$array = range(1,9);
$array = range(1, 9);

$result = Collection\firstN($array, 3);
$this->assertEquals([1, 2, 3], $result);
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Collection/CollectionFirstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*/
class CollectionFirstTest extends \PHPUnit_Framework_TestCase
{

public function testFirst()
{
$array = range(1,9);
$array = range(1, 9);

$result = Collection\first($array);
$this->assertEquals(1, $result);
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Collection/CollectionLastNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*/
class CollectionLastNTest extends \PHPUnit_Framework_TestCase
{

public function testLast()
{
$array = range(1,9);
$array = range(1, 9);

$result = Collection\lastN($array, 3);
$this->assertEquals([7, 8, 9], $result);
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/Collection/CollectionLastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
*/
class CollectionLastTest extends \PHPUnit_Framework_TestCase
{

public function testLast()
{
$array = range(1,9);
$array = range(1, 9);

$result = Collection\last($array);
$this->assertEquals(9, $result);
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/IfSetOrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIsNotSet()
$this->assertNull(Funct\ifSetOr($foo));
$this->assertEquals('bar', Funct\ifSetOr($foo2, 'bar'));
}

public function testIsSet()
{
$foo = 'foo';
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Invoke/InvokeIfIssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Funct\Tests\Invoke;

use Funct\Invoke;
use Funct\Tests\Fixtures\SampleObject;;
use Funct\Tests\Fixtures\SampleObject;

/**
* Class InvokeIfIssetTest
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Invoke/InvokeIfNotEmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Funct\Tests\Invoke;

use Funct\Invoke;
use Funct\Tests\Fixtures\SampleObject;;
use Funct\Tests\Fixtures\SampleObject;

/**
* Class InvokeIfNotEmptyTest
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Objects/AssignIfIssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
class AssignIfIssetTest extends \PHPUnit_Framework_TestCase
{

public function testMethod()
{
$object = new \stdClass();
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Strings/StringsChompLeftTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Funct\Tests\Strings;

use Funct\Strings;;
use Funct\Strings;

/**
* Class StringsChompLeftTest
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Strings/StringsIncludesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function dataStringIncludes()
$out[] = ['foo bar', 'foo', true];
$out[] = ['foo&%$bar@;/', 'bar', true];
$out[] = ['foo BAR', 'bar', false];

return $out;
}

Expand Down
18 changes: 12 additions & 6 deletions src/Tests/Strings/StringsLatinizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ public function dataStringLatinize()
{
$out = [];

$out[] = ['Dès Noël où un zéphyr haï me vêt de glaçons würmiens je dîne d’exquis rôtis de bœuf au kir à l’aÿ d’âge mûr & cætera !',
'Des Noel ou un zephyr hai me vet de glacons wurmiens je dine d’exquis rotis de boeuf au kir a l’ay d’age mur & caetera !'];
$out[] = ['Benjamín pidió una bebida de kiwi y fresa; Noé, sin vergüenza, la más exquisita champaña del menú.',
'Benjamin pidio una bebida de kiwi y fresa; Noe, sin verguenza, la mas exquisita champana del menu.'];
$out[] = ['Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.',
'Falsches Uben von Xylophonmusik qualt jeden grosseren Zwerg.'];
$out[] = [
'Dès Noël où un zéphyr haï me vêt de glaçons würmiens je dîne d’exquis rôtis de bœuf au kir à l’aÿ d’âge mûr & cætera !',
'Des Noel ou un zephyr hai me vet de glacons wurmiens je dine d’exquis rotis de boeuf au kir a l’ay d’age mur & caetera !'
];
$out[] = [
'Benjamín pidió una bebida de kiwi y fresa; Noé, sin vergüenza, la más exquisita champaña del menú.',
'Benjamin pidio una bebida de kiwi y fresa; Noe, sin verguenza, la mas exquisita champana del menu.'
];
$out[] = [
'Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.',
'Falsches Uben von Xylophonmusik qualt jeden grosseren Zwerg.'
];

return $out;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Strings/StringsToLowerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ public function testStringToLower($input, $mb, $expected)
{
$this->assertEquals($expected, Strings\toLower($input, $mb));
}
}
}