Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Rename class #619

Merged
merged 1 commit into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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