From fc4756f157fcd2207d4d9bd4e2c3b3e870abbd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 29 Dec 2021 13:35:17 +0100 Subject: [PATCH] Fix: Rename class --- CHANGELOG.md | 2 + README.md | 58 +++++++++---------- ...zer.php => WithFinalNewLineNormalizer.php} | 2 +- ...php => WithFinalNewLineNormalizerTest.php} | 8 +-- 4 files changed, 36 insertions(+), 34 deletions(-) rename src/{FinalNewLineNormalizer.php => WithFinalNewLineNormalizer.php} (87%) rename test/Unit/{FinalNewLineNormalizerTest.php => WithFinalNewLineNormalizerTest.php} (78%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3570a701..c291692b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ For a full diff see [`1.0.3...main`][1.0.3...main]. - Renamed `Format\JsonEncodeOptions::value()` to `Format\JsonEncodeOptions::toInt()` ([#603]), by [@localheinz] - Extracted `Format\Format::create()` as named constructor and reduced visibility of `__construct` to `private` ([#608]), by [@localheinz] - Stopped composing `Format\Format` into `Json` ([#616]), by [@localheinz] +- Renamed `FinalNewLineNormalizer` to `WithFinalNewLineNormalizer` ([#618]), by [@localheinz] ### Fixed @@ -440,6 +441,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0]. [#603]: https://github.com/ergebnis/json-normalizer/pull/603 [#608]: https://github.com/ergebnis/json-normalizer/pull/608 [#616]: https://github.com/ergebnis/json-normalizer/pull/616 +[#618]: https://github.com/ergebnis/json-normalizer/pull/618 [@BackEndTea]: https://github.com/BackEndTea [@dependabot]: https://github.com/dependabot diff --git a/README.md b/README.md index 72193e0a..0708b5d1 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,12 @@ This package comes with the following generic normalizers: - [`Ergebnis\Json\Normalizer\AutoFormatNormalizer`](#autoformatnormalizer) - [`Ergebnis\Json\Normalizer\CallableNormalizer`](#callablenormalizer) - [`Ergebnis\Json\Normalizer\ChainNormalizer`](#chainnormalizer) -- [`Ergebnis\Json\Normalizer\FinalNewLineNormalizer`](#finalnewlinenormalizer) - [`Ergebnis\Json\Normalizer\FixedFormatNormalizer`](#fixedformatnormalizer) - [`Ergebnis\Json\Normalizer\IndentNormalizer`](#indentnormalizer) - [`Ergebnis\Json\Normalizer\JsonEncodeNormalizer`](#jsonencodenormalizer) - [`Ergebnis\Json\Normalizer\NoFinalNewLineNormalizer`](#nofinalnewlinenormalizer) - [`Ergebnis\Json\Normalizer\SchemaNormalizer`](#schemanormalizer) +- [`Ergebnis\Json\Normalizer\WithFinalNewLineNormalizer`](#withfinalnewlinenormalizer) :bulb: All of these normalizers implement the `Ergebnis\Json\Normalizer\NormalizerInterface`. @@ -150,7 +150,7 @@ $normalizer = new Normalizer\ChainNormalizer( $indent, new Printer\Printer() ), - new Normalizer\FinalNewLineNormalizer() + new Normalizer\WithFinalNewLineNormalizer() ); $normalized = $normalizer->normalize($json); @@ -160,33 +160,6 @@ The normalized version will now contain the result of applying all normalizers i :bulb: Be careful with the order of the normalizers, as one normalizer might override changes a previous normalizer applied. -#### `FinalNewLineNormalizer` - -When you want to ensure that a JSON file has a single final new line, you can use the `FinalNewLineNormalizer`. - -```php -normalize($json); -``` - -The normalized version will now have a single final new line. - #### `FixedFormatNormalizer` When you want to normalize a JSON file with an implementation of `NormalizerInterface`, but apply a fixed formatting, you can use the `FixedFormatNormalizer`. @@ -360,6 +333,33 @@ The normalized version will now be structured according to the JSON schema (in t :bulb: For more information about JSON schema, visit [json-schema.org](http://json-schema.org). +#### `WithFinalNewLineNormalizer` + +When you want to ensure that a JSON file has a single final new line, you can use the `WithFinalNewLineNormalizer`. + +```php +normalize($json); +``` + +The normalized version will now have a single final new line. + ### Vendor-specific normalizers This package comes with the following vendor-specific normalizers: diff --git a/src/FinalNewLineNormalizer.php b/src/WithFinalNewLineNormalizer.php similarity index 87% rename from src/FinalNewLineNormalizer.php rename to src/WithFinalNewLineNormalizer.php index 299dc7da..8165c0c1 100644 --- a/src/FinalNewLineNormalizer.php +++ b/src/WithFinalNewLineNormalizer.php @@ -13,7 +13,7 @@ namespace Ergebnis\Json\Normalizer; -final class FinalNewLineNormalizer implements NormalizerInterface +final class WithFinalNewLineNormalizer implements NormalizerInterface { public function normalize(Json $json): Json { diff --git a/test/Unit/FinalNewLineNormalizerTest.php b/test/Unit/WithFinalNewLineNormalizerTest.php similarity index 78% rename from test/Unit/FinalNewLineNormalizerTest.php rename to test/Unit/WithFinalNewLineNormalizerTest.php index 9f09f76f..77dbb691 100644 --- a/test/Unit/FinalNewLineNormalizerTest.php +++ b/test/Unit/WithFinalNewLineNormalizerTest.php @@ -13,17 +13,17 @@ namespace Ergebnis\Json\Normalizer\Test\Unit; -use Ergebnis\Json\Normalizer\FinalNewLineNormalizer; use Ergebnis\Json\Normalizer\Json; +use Ergebnis\Json\Normalizer\WithFinalNewLineNormalizer; /** * @internal * - * @covers \Ergebnis\Json\Normalizer\FinalNewLineNormalizer + * @covers \Ergebnis\Json\Normalizer\WithFinalNewLineNormalizer * * @uses \Ergebnis\Json\Normalizer\Json */ -final class FinalNewLineNormalizerTest extends AbstractNormalizerTestCase +final class WithFinalNewLineNormalizerTest extends AbstractNormalizerTestCase { /** * @dataProvider \Ergebnis\DataProvider\StringProvider::blank() @@ -39,7 +39,7 @@ public function testNormalizeEnsuresSingleFinalNewLine(string $whitespace): void JSON ); - $normalizer = new FinalNewLineNormalizer(); + $normalizer = new WithFinalNewLineNormalizer(); $normalized = $normalizer->normalize($json);