Skip to content

Commit 47bc7c6

Browse files
committed
Issue #6: locator builder fixed and updated
1 parent ff69b2a commit 47bc7c6

12 files changed

+37
-17
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Issue #5: `ResultInterface::get()` method added.
10+
### Fixed
11+
- Issue #6: locator builder moved to correct namespace.
1012

1113
## [0.6.3] - 2019-11-18
1214
### Fixed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Remorhaz\JSON\Pointer\Locator\Exception;
5+
6+
use Remorhaz\JSON\Pointer\Exception\ExceptionInterface as PointerExceptionInterface;
7+
8+
interface ExceptionInterface extends PointerExceptionInterface
9+
{
10+
}

src/Parser/Exception/LocatorAlreadyBuiltException.php src/Locator/Exception/LocatorAlreadyBuiltException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Remorhaz\JSON\Pointer\Parser\Exception;
4+
namespace Remorhaz\JSON\Pointer\Locator\Exception;
55

66
use LogicException;
77
use Throwable;

src/Parser/LocatorBuilder.php src/Locator/LocatorBuilder.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Remorhaz\JSON\Pointer\Parser;
5-
6-
use Remorhaz\JSON\Pointer\Locator\Locator;
7-
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
8-
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
4+
namespace Remorhaz\JSON\Pointer\Locator;
95

106
final class LocatorBuilder implements LocatorBuilderInterface
117
{
@@ -16,6 +12,11 @@ final class LocatorBuilder implements LocatorBuilderInterface
1612

1713
private $references = [];
1814

15+
public static function create(): LocatorBuilderInterface
16+
{
17+
return new self(new ReferenceFactory);
18+
}
19+
1920
public function __construct(ReferenceFactoryInterface $referenceFactory)
2021
{
2122
$this->referenceFactory = $referenceFactory;

src/Parser/LocatorBuilderInterface.php src/Locator/LocatorBuilderInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Remorhaz\JSON\Pointer\Parser;
5-
6-
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
4+
namespace Remorhaz\JSON\Pointer\Locator;
75

86
interface LocatorBuilderInterface
97
{

src/Parser/Ll1ParserFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Remorhaz\JSON\Pointer\Parser;
55

6+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
67
use Remorhaz\JSON\Pointer\TokenMatcher;
78
use Remorhaz\UniLex\Exception as UnilexException;
89
use Remorhaz\UniLex\Grammar\ContextFree\GrammarInterface;

src/Parser/Ll1ParserFactoryInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Remorhaz\JSON\Pointer\Parser;
55

6+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
67
use Remorhaz\UniLex\Parser\LL1\Parser as Ll1Parser;
78

89
interface Ll1ParserFactoryInterface

src/Parser/Parser.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Remorhaz\JSON\Pointer\Parser;
55

6+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilder;
67
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
78
use Remorhaz\JSON\Pointer\Locator\ReferenceFactory;
89
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;

src/Parser/TranslationScheme.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Remorhaz\JSON\Pointer\Parser;
55

6+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
67
use Remorhaz\UniLex\Grammar\SDD\TranslationSchemeInterface;
78
use Remorhaz\UniLex\Lexer\Token;
89
use Remorhaz\UniLex\Parser\Production;

tests/Parser/Exception/LocatorAlreadyBuiltExceptionTest.php tests/Locator/Exception/LocatorAlreadyBuiltExceptionTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Remorhaz\JSON\Pointer\Test\Parser\Exception;
4+
namespace Remorhaz\JSON\Pointer\Test\Locator\Exception;
55

66
use Exception;
77
use PHPUnit\Framework\TestCase;
8-
use Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException;
8+
use Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException;
99

1010
/**
11-
* @covers \Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException
11+
* @covers \Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException
1212
*/
1313
class LocatorAlreadyBuiltExceptionTest extends TestCase
1414
{

tests/Parser/LocatorBuilderTest.php tests/Locator/LocatorBuilderTest.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Remorhaz\JSON\Pointer\Test\Parser;
4+
namespace Remorhaz\JSON\Pointer\Test\Locator;
55

66
use PHPUnit\Framework\TestCase;
77
use Remorhaz\JSON\Pointer\Locator\ListedReferenceInterface;
88
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
99
use Remorhaz\JSON\Pointer\Locator\ReferenceInterface;
10-
use Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException;
11-
use Remorhaz\JSON\Pointer\Parser\LocatorBuilder;
10+
use Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException;
11+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilder;
1212
use function array_map;
1313

1414
/**
15-
* @covers \Remorhaz\JSON\Pointer\Parser\LocatorBuilder
15+
* @covers \Remorhaz\JSON\Pointer\Locator\LocatorBuilder
1616
*/
1717
class LocatorBuilderTest extends TestCase
1818
{
1919

20+
public function testCreate_Always_ReturnsLocatorBuilderInstance(): void
21+
{
22+
self::assertInstanceOf(LocatorBuilder::class, LocatorBuilder::create());
23+
}
24+
2025
public function testGetLocator_ReferencesNotAdded_ReturnsEmptyLocator(): void
2126
{
2227
$builder = new LocatorBuilder($this->createMock(ReferenceFactoryInterface::class));

tests/Parser/TranslationSchemeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Remorhaz\JSON\Pointer\Test\Parser;
55

66
use PHPUnit\Framework\TestCase;
7-
use Remorhaz\JSON\Pointer\Parser\LocatorBuilderInterface;
7+
use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
88
use Remorhaz\JSON\Pointer\Parser\TranslationScheme;
99
use Remorhaz\JSON\Pointer\TokenMatcher;
1010
use Remorhaz\UniLex\Exception as UniLexException;

0 commit comments

Comments
 (0)