Skip to content

Commit

Permalink
Fix: Rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 28, 2022
1 parent cab2b33 commit 836b334
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ For a full diff see [`1.0.0...2.0.0`][1.0.0...2.0.0].

## Changed

- Renamed named constructors and accessors of `Exception\InvalidJsonPointer`, `JsonPointer`, and `ReferenceToken` ([#4]), by [@localheinz]
- Renamed named constructors and accessors of `Exception\InvalidJsonPointer`, `JsonPointer`, and `ReferenceToken` ([#4]) and ([#5]), by [@localheinz]

- `Exception\InvalidJsonPointer::fromString()` to `JsonPointer::fromJsonString()`
- `Exception\InvalidJsonPointer::fromString()` to `Exception\InvalidJsonPointer::fromJsonString()`
- `JsonPointer::fromString()` to `JsonPointer::fromJsonString()`
- `JsonPointer::toString()` to `JsonPointer::toJsonString()`
- `ReferenceToken::fromEscapedString()` to `ReferenceToken::fromJsonString()`
Expand All @@ -40,5 +40,6 @@ For a full diff see [`a5ba52c...1.0.0`][a5ba52c...1.0.0].
[#1]: https://github.com/ergebnis/json-pointer/pull/1
[#2]: https://github.com/ergebnis/json-pointer/pull/2
[#4]: https://github.com/ergebnis/json-pointer/pull/4
[#5]: https://github.com/ergebnis/json-pointer/pull/5

[@localheinz]: https://github.com/localheinz
2 changes: 1 addition & 1 deletion src/Exception/InvalidReferenceToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

final class InvalidReferenceToken extends \InvalidArgumentException implements Exception
{
public static function fromString(string $value): self
public static function fromJsonString(string $value): self
{
return new self(\sprintf(
'Value "%s" does not appear to be a valid JSON Pointer reference token.',
Expand Down
2 changes: 1 addition & 1 deletion src/ReferenceToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function fromInt(int $value): self
public static function fromJsonString(string $value): self
{
if (1 !== \preg_match('/^(?P<referenceToken>((?P<unescaped>[\x00-\x2E]|[\x30-\x7D]|[\x7F-\x{10FFFF}])|(?P<escaped>~[01]))*)$/u', $value)) {
throw Exception\InvalidReferenceToken::fromString($value);
throw Exception\InvalidReferenceToken::fromJsonString($value);
}

return new self($value);
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Exception/InvalidReferenceTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ final class InvalidReferenceTokenTest extends Framework\TestCase
{
use Test\Util\Helper;

public function testFromStringReturnsInvalidReferenceToken(): void
public function testFromJsonStringReturnsInvalidReferenceToken(): void
{
$value = self::faker()->word();

$exception = Exception\InvalidReferenceToken::fromString($value);
$exception = Exception\InvalidReferenceToken::fromJsonString($value);

$message = \sprintf(
'Value "%s" does not appear to be a valid JSON Pointer reference token.',
Expand Down

0 comments on commit 836b334

Please sign in to comment.