From f07e7c65efeca7e9d86d704d456acc5c0d205ed8 Mon Sep 17 00:00:00 2001 From: maks-rafalko Date: Sat, 31 Oct 2020 17:10:14 +0300 Subject: [PATCH] Implement UnwrapLtrim mutator --- resources/schema.json | 1 + src/Mutator/ProfileList.php | 2 + src/Mutator/Unwrap/UnwrapLtrim.php | 72 +++++++ .../Mutator/Unwrap/UnwrapLtrimTest.php | 191 ++++++++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 src/Mutator/Unwrap/UnwrapLtrim.php create mode 100644 tests/phpunit/Mutator/Unwrap/UnwrapLtrimTest.php diff --git a/resources/schema.json b/resources/schema.json index 117bdae6a..2ddaf041c 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -349,6 +349,7 @@ "UnwrapArrayUnique": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapArrayValues": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapLcFirst": { "$ref": "#/definitions/default-mutator-config" }, + "UnwrapLtrim": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrRepeat": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrReplace": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrToLower": { "$ref": "#/definitions/default-mutator-config" }, diff --git a/src/Mutator/ProfileList.php b/src/Mutator/ProfileList.php index 2cc11e3a6..8b2cde8f1 100644 --- a/src/Mutator/ProfileList.php +++ b/src/Mutator/ProfileList.php @@ -239,6 +239,7 @@ final class ProfileList Mutator\Unwrap\UnwrapArrayUnique::class, Mutator\Unwrap\UnwrapArrayValues::class, Mutator\Unwrap\UnwrapLcFirst::class, + Mutator\Unwrap\UnwrapLtrim::class, Mutator\Unwrap\UnwrapStrRepeat::class, Mutator\Unwrap\UnwrapStrReplace::class, Mutator\Unwrap\UnwrapStrToLower::class, @@ -421,6 +422,7 @@ final class ProfileList 'UnwrapArrayUnique' => Mutator\Unwrap\UnwrapArrayUnique::class, 'UnwrapArrayValues' => Mutator\Unwrap\UnwrapArrayValues::class, 'UnwrapLcFirst' => Mutator\Unwrap\UnwrapLcFirst::class, + 'UnwrapLtrim' => Mutator\Unwrap\UnwrapLtrim::class, 'UnwrapStrRepeat' => Mutator\Unwrap\UnwrapStrRepeat::class, 'UnwrapStrReplace' => Mutator\Unwrap\UnwrapStrReplace::class, 'UnwrapStrToLower' => Mutator\Unwrap\UnwrapStrToLower::class, diff --git a/src/Mutator/Unwrap/UnwrapLtrim.php b/src/Mutator/Unwrap/UnwrapLtrim.php new file mode 100644 index 000000000..621d7cf17 --- /dev/null +++ b/src/Mutator/Unwrap/UnwrapLtrim.php @@ -0,0 +1,72 @@ +doTest($input, $expected); + } + + public function mutationsProvider(): iterable + { + yield 'It mutates correctly when provided with a string' => [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' +bar()); +PHP + , + <<<'PHP' +bar(); +PHP + ]; + + yield 'It mutates correctly when provided with a more complex situation' => [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' +