diff --git a/resources/schema.json b/resources/schema.json index 2abac35b6..35efdd2e5 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -357,6 +357,7 @@ "UnwrapStrShuffle": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrToLower": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrToUpper": { "$ref": "#/definitions/default-mutator-config" }, + "UnwrapSubstr": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapTrim": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapUcFirst": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapUcWords": { "$ref": "#/definitions/default-mutator-config" }, diff --git a/src/Mutator/ProfileList.php b/src/Mutator/ProfileList.php index a0b2af87a..6d1669d6f 100644 --- a/src/Mutator/ProfileList.php +++ b/src/Mutator/ProfileList.php @@ -247,6 +247,7 @@ final class ProfileList Mutator\Unwrap\UnwrapStrShuffle::class, Mutator\Unwrap\UnwrapStrToLower::class, Mutator\Unwrap\UnwrapStrToUpper::class, + Mutator\Unwrap\UnwrapSubstr::class, Mutator\Unwrap\UnwrapTrim::class, Mutator\Unwrap\UnwrapUcFirst::class, Mutator\Unwrap\UnwrapUcWords::class, @@ -433,6 +434,7 @@ final class ProfileList 'UnwrapStrShuffle' => Mutator\Unwrap\UnwrapStrShuffle::class, 'UnwrapStrToLower' => Mutator\Unwrap\UnwrapStrToLower::class, 'UnwrapStrToUpper' => Mutator\Unwrap\UnwrapStrToUpper::class, + 'UnwrapSubstr' => Mutator\Unwrap\UnwrapSubstr::class, 'UnwrapTrim' => Mutator\Unwrap\UnwrapTrim::class, 'UnwrapUcFirst' => Mutator\Unwrap\UnwrapUcFirst::class, 'UnwrapUcWords' => Mutator\Unwrap\UnwrapUcWords::class, diff --git a/src/Mutator/Unwrap/UnwrapSubstr.php b/src/Mutator/Unwrap/UnwrapSubstr.php new file mode 100644 index 000000000..cd576b02e --- /dev/null +++ b/src/Mutator/Unwrap/UnwrapSubstr.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(), 0, -1); +PHP + , + <<<'PHP' +bar(); +PHP + ]; + + yield 'It mutates correctly when provided with a more complex situation' => [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' +