Skip to content

Commit

Permalink
Merge pull request #619 from ergebnis/fix/rename
Browse files Browse the repository at this point in the history
Fix: Rename class
  • Loading branch information
localheinz committed Dec 29, 2021
2 parents 9612c27 + 98ac1b9 commit 1dd2d3f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ For a full diff see [`1.0.3...main`][1.0.3...main].
- 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]
- Renamed `NoFinalNewLineNormalizer` to `WithoutFinalNewLineNormalizer` ([#619]), by [@localheinz]

### Fixed

Expand Down Expand Up @@ -442,6 +443,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#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
[#619]: https://github.com/ergebnis/json-normalizer/pull/619

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
56 changes: 28 additions & 28 deletions README.md
Expand Up @@ -35,9 +35,9 @@ This package comes with the following generic normalizers:
- [`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)
- [`Ergebnis\Json\Normalizer\WithoutFinalNewLineNormalizer`](#withoutfinalnewlinenormalizer)

:bulb: All of these normalizers implement the `Ergebnis\Json\Normalizer\NormalizerInterface`.

Expand Down Expand Up @@ -254,33 +254,6 @@ The normalized version will now be encoded with `$jsonEncodeOptions`.

:bulb: For reference, see [`json_encode()`](http://php.net/manual/en/function.json-encode.php) and the corresponding [JSON constants](http://php.net/manual/en/json.constants.php).

#### `NoFinalNewLineNormalizer`

When you want to ensure that a JSON file does not have a final new line, you can use the `NoFinalNewLineNormalizer`.

```php
<?php

use Ergebnis\Json\Normalizer;

$encoded = <<<'JSON'
{
"name": "Andreas Möller",
"url": "https://localheinz.com"
}


JSON;

$json = Normalizer\Json::fromEncoded($encoded);

$normalizer = new Normalizer\NoFinalNewLineNormalizer();

$normalized = $normalizer->normalize($json);
```

The normalized version will now not have a final new line or any whitespace at the end.

#### `SchemaNormalizer`

When you want to rebuild a JSON file according to a JSON schema, you can use the `SchemaNormalizer`.
Expand Down Expand Up @@ -360,6 +333,33 @@ $normalized = $normalizer->normalize($json);

The normalized version will now have a single final new line.

#### `WithoutFinalNewLineNormalizer`

When you want to ensure that a JSON file does not have a final new line, you can use the `WithoutFinalNewLineNormalizer`.

```php
<?php

use Ergebnis\Json\Normalizer;

$encoded = <<<'JSON'
{
"name": "Andreas Möller",
"url": "https://localheinz.com"
}


JSON;

$json = Normalizer\Json::fromEncoded($encoded);

$normalizer = new Normalizer\WithoutFinalNewLineNormalizer();

$normalized = $normalizer->normalize($json);
```

The normalized version will now not have a final new line or any whitespace at the end.

### Vendor-specific normalizers

This package comes with the following vendor-specific normalizers:
Expand Down
Expand Up @@ -13,7 +13,7 @@

namespace Ergebnis\Json\Normalizer;

final class NoFinalNewLineNormalizer implements NormalizerInterface
final class WithoutFinalNewLineNormalizer implements NormalizerInterface
{
public function normalize(Json $json): Json
{
Expand Down
Expand Up @@ -14,16 +14,16 @@
namespace Ergebnis\Json\Normalizer\Test\Unit;

use Ergebnis\Json\Normalizer\Json;
use Ergebnis\Json\Normalizer\NoFinalNewLineNormalizer;
use Ergebnis\Json\Normalizer\WithoutFinalNewLineNormalizer;

/**
* @internal
*
* @covers \Ergebnis\Json\Normalizer\NoFinalNewLineNormalizer
* @covers \Ergebnis\Json\Normalizer\WithoutFinalNewLineNormalizer
*
* @uses \Ergebnis\Json\Normalizer\Json
*/
final class NoFinalNewLineNormalizerTest extends AbstractNormalizerTestCase
final class WithoutFinalNewLineNormalizerTest extends AbstractNormalizerTestCase
{
/**
* @dataProvider \Ergebnis\DataProvider\StringProvider::blank()
Expand All @@ -39,7 +39,7 @@ public function testNormalizeRemovesAllWhitespaceFromEndOfJson(string $whitespac
JSON
);

$normalizer = new NoFinalNewLineNormalizer();
$normalizer = new WithoutFinalNewLineNormalizer();

$normalized = $normalizer->normalize($json);

Expand Down

0 comments on commit 1dd2d3f

Please sign in to comment.