Skip to content

Commit

Permalink
Issue #6: locator builder fixed and updated
Browse files Browse the repository at this point in the history
  • Loading branch information
remorhaz committed Nov 20, 2019
1 parent ff69b2a commit 47bc7c6
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Issue #5: `ResultInterface::get()` method added.
### Fixed
- Issue #6: locator builder moved to correct namespace.

## [0.6.3] - 2019-11-18
### Fixed
Expand Down
10 changes: 10 additions & 0 deletions src/Locator/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Locator\Exception;

use Remorhaz\JSON\Pointer\Exception\ExceptionInterface as PointerExceptionInterface;

interface ExceptionInterface extends PointerExceptionInterface
{
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Parser\Exception;
namespace Remorhaz\JSON\Pointer\Locator\Exception;

use LogicException;
use Throwable;
Expand Down
11 changes: 6 additions & 5 deletions src/Parser/LocatorBuilder.php → src/Locator/LocatorBuilder.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\Locator;
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
namespace Remorhaz\JSON\Pointer\Locator;

final class LocatorBuilder implements LocatorBuilderInterface
{
Expand All @@ -16,6 +12,11 @@ final class LocatorBuilder implements LocatorBuilderInterface

private $references = [];

public static function create(): LocatorBuilderInterface
{
return new self(new ReferenceFactory);
}

public function __construct(ReferenceFactoryInterface $referenceFactory)
{
$this->referenceFactory = $referenceFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
namespace Remorhaz\JSON\Pointer\Locator;

interface LocatorBuilderInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/Ll1ParserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
use Remorhaz\JSON\Pointer\TokenMatcher;
use Remorhaz\UniLex\Exception as UnilexException;
use Remorhaz\UniLex\Grammar\ContextFree\GrammarInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Parser/Ll1ParserFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
use Remorhaz\UniLex\Parser\LL1\Parser as Ll1Parser;

interface Ll1ParserFactoryInterface
Expand Down
1 change: 1 addition & 0 deletions src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\LocatorBuilder;
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
use Remorhaz\JSON\Pointer\Locator\ReferenceFactory;
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Parser/TranslationScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Remorhaz\JSON\Pointer\Parser;

use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
use Remorhaz\UniLex\Grammar\SDD\TranslationSchemeInterface;
use Remorhaz\UniLex\Lexer\Token;
use Remorhaz\UniLex\Parser\Production;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Test\Parser\Exception;
namespace Remorhaz\JSON\Pointer\Test\Locator\Exception;

use Exception;
use PHPUnit\Framework\TestCase;
use Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException;
use Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException;

/**
* @covers \Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException
* @covers \Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException
*/
class LocatorAlreadyBuiltExceptionTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<?php
declare(strict_types=1);

namespace Remorhaz\JSON\Pointer\Test\Parser;
namespace Remorhaz\JSON\Pointer\Test\Locator;

use PHPUnit\Framework\TestCase;
use Remorhaz\JSON\Pointer\Locator\ListedReferenceInterface;
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
use Remorhaz\JSON\Pointer\Locator\ReferenceInterface;
use Remorhaz\JSON\Pointer\Parser\Exception\LocatorAlreadyBuiltException;
use Remorhaz\JSON\Pointer\Parser\LocatorBuilder;
use Remorhaz\JSON\Pointer\Locator\Exception\LocatorAlreadyBuiltException;
use Remorhaz\JSON\Pointer\Locator\LocatorBuilder;
use function array_map;

/**
* @covers \Remorhaz\JSON\Pointer\Parser\LocatorBuilder
* @covers \Remorhaz\JSON\Pointer\Locator\LocatorBuilder
*/
class LocatorBuilderTest extends TestCase
{

public function testCreate_Always_ReturnsLocatorBuilderInstance(): void
{
self::assertInstanceOf(LocatorBuilder::class, LocatorBuilder::create());
}

public function testGetLocator_ReferencesNotAdded_ReturnsEmptyLocator(): void
{
$builder = new LocatorBuilder($this->createMock(ReferenceFactoryInterface::class));
Expand Down
2 changes: 1 addition & 1 deletion tests/Parser/TranslationSchemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Remorhaz\JSON\Pointer\Test\Parser;

use PHPUnit\Framework\TestCase;
use Remorhaz\JSON\Pointer\Parser\LocatorBuilderInterface;
use Remorhaz\JSON\Pointer\Locator\LocatorBuilderInterface;
use Remorhaz\JSON\Pointer\Parser\TranslationScheme;
use Remorhaz\JSON\Pointer\TokenMatcher;
use Remorhaz\UniLex\Exception as UniLexException;
Expand Down

0 comments on commit 47bc7c6

Please sign in to comment.