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 method #603

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 @@ -14,6 +14,7 @@ For a full diff see [`1.0.3...main`][1.0.3...main].
- Dropped support for PHP 7.3 ([#573]), by [@localheinz]
- Renamed `Format::__toString()`, `Indent::__toString()`, and `Json::__toString()` to `Format::toString()`, `Indent::toString()`, and `Json::toString()`, requiring consumers to explicitly invoke methods instead of allowing to cast to `string` ([#589]), by [@localheinz]
- Started using the `SchemaValidator` provided by `ergebnis/json-schema-validator` ([#595]), by [@localheinz]
- Renamed `Format\JsonEncodeOptions::value()` to `Format\JsonEncodeOptions::toInt()` ([#603]), by [@localheinz]

### Fixed

Expand Down Expand Up @@ -434,6 +435,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#590]: https://github.com/ergebnis/json-normalizer/pull/590
[#595]: https://github.com/ergebnis/json-normalizer/pull/595
[#597]: https://github.com/ergebnis/json-normalizer/pull/597
[#603]: https://github.com/ergebnis/json-normalizer/pull/603

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function format(
/** @var string $encoded */
$encoded = \json_encode(
$json->decoded(),
$format->jsonEncodeOptions()->value(),
$format->jsonEncodeOptions()->toInt(),
);

$printed = $this->printer->print(
Expand Down
2 changes: 1 addition & 1 deletion src/Format/JsonEncodeOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function fromJson(Json $json): self
return self::fromInt($jsonEncodeOptions);
}

public function value(): int
public function toInt(): int
{
return $this->value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonEncodeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function normalize(Json $json): Json
/** @var string $encodedWithJsonEncodeOptions */
$encodedWithJsonEncodeOptions = \json_encode(
$json->decoded(),
$this->jsonEncodeOptions->value(),
$this->jsonEncodeOptions->toInt(),
);

return Json::fromEncoded($encodedWithJsonEncodeOptions);
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Format/JsonEncodeOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testFromIntReturnsJsonEncodeOptions(int $value): void
{
$jsonEncodeOptions = Format\JsonEncodeOptions::fromInt($value);

self::assertSame($value, $jsonEncodeOptions->value());
self::assertSame($value, $jsonEncodeOptions->toInt());
}

/**
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testFromJsonReturnsJsonEncodeOptions(int $value, string $encoded

$jsonEncodeOptions = Format\JsonEncodeOptions::fromJson($json);

self::assertSame($value, $jsonEncodeOptions->value());
self::assertSame($value, $jsonEncodeOptions->toInt());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testFromEncodedReturnsJson(string $encoded): void

$format = Format\Format::fromJson($json);

self::assertSame($format->jsonEncodeOptions()->value(), $json->format()->jsonEncodeOptions()->value());
self::assertSame($format->jsonEncodeOptions()->toInt(), $json->format()->jsonEncodeOptions()->toInt());
self::assertSame($format->indent()->toString(), $json->format()->indent()->toString());
self::assertSame($format->newLine()->toString(), $json->format()->newLine()->toString());
self::assertSame($format->hasFinalNewLine(), $json->format()->hasFinalNewLine());
Expand Down