Skip to content

Commit

Permalink
Rename /NotMatched namepsace to /Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jun 4, 2019
1 parent c79e98f commit fbf43f5
Show file tree
Hide file tree
Showing 30 changed files with 75 additions and 80 deletions.
@@ -1,9 +1,9 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\FirstGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\MethodGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\FirstGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\MethodGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Internal\Subjectable;

class GroupNotMatchedException extends CleanRegexException
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Group;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class FirstGroupMessage implements NotMatchedMessage
{
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Group;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;
use function sprintf;

class GroupMessage implements NotMatchedMessage
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Group;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;
use function sprintf;

class MethodGroupMessage implements NotMatchedMessage
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Group;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class ReplacementWithUnmatchedGroupMessage implements NotMatchedMessage
{
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages;

class InternalExceptionMessage implements NotMatchedMessage
{
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\MissingReplacement;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\MissingReplacement;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class ForGroupMessage implements NotMatchedMessage
{
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\MissingReplacement;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\MissingReplacement;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class ForMatchMessage implements NotMatchedMessage
{
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NonReplaced;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\NonReplaced;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class NonMatchedMessage implements NotMatchedMessage
{
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\NotMatched;
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages;

interface NotMatchedMessage
{
Expand Down
@@ -0,0 +1,20 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject;

use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class FirstGroupSubjectMessage implements NotMatchedMessage
{
/** @var string|int */
private $nameOrIndex;

public function __construct($nameOrIndex)
{
$this->nameOrIndex = $nameOrIndex;
}

public function getMessage(): string
{
return "Expected to get group '$this->nameOrIndex' from the first match, but subject was not matched at all";
}
}
@@ -0,0 +1,12 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject;

use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;

class FirstMatchMessage implements NotMatchedMessage
{
public function getMessage(): string
{
return 'Expected to get first match, but subject was not matched';
}
}

This file was deleted.

This file was deleted.

@@ -1,8 +1,8 @@
<?php
namespace TRegx\CleanRegex\Exception\CleanRegex;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Subject\FirstGroupSubjectMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject\FirstGroupSubjectMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Internal\Subjectable;

class SubjectNotMatchedException extends CleanRegexException
Expand Down
Expand Up @@ -2,7 +2,7 @@
namespace TRegx\CleanRegex\Internal\Factory;

use Throwable;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;
use TRegx\CleanRegex\Internal\SignatureExceptionFactory;
use TRegx\CleanRegex\Internal\Subjectable;
use TRegx\CleanRegex\Match\Details\NotMatched;
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Internal\Match\Details\Group;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\GroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\GroupMessage;
use TRegx\CleanRegex\Internal\Factory\GroupExceptionFactory;
use TRegx\CleanRegex\Internal\Factory\NotMatchedOptionalWorker;
use TRegx\CleanRegex\Internal\GroupNameIndexAssign;
Expand Down
Expand Up @@ -6,7 +6,7 @@
use Throwable;
use TRegx\CleanRegex\Exception\CleanRegex\ClassExpectedException;
use TRegx\CleanRegex\Exception\CleanRegex\NoSuitableConstructorException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;
use TypeError;
use function class_exists;
use function interface_exists;
Expand Down
2 changes: 1 addition & 1 deletion src/TRegx/CleanRegex/Match/AbstractMatchPattern.php
Expand Up @@ -5,7 +5,7 @@
use Countable;
use EmptyIterator;
use Iterator;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\SubjectNotMatchedException;
use TRegx\CleanRegex\Internal\Factory\NotMatchedOptionalWorker;
use TRegx\CleanRegex\Internal\GroupLimit\GroupLimitFactory;
Expand Down
Expand Up @@ -4,8 +4,8 @@
use TRegx\CleanRegex\Exception\CleanRegex\GroupNotMatchedException;
use TRegx\CleanRegex\Exception\CleanRegex\InternalCleanRegexException;
use TRegx\CleanRegex\Exception\CleanRegex\MissingReplacementKeyException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\MissingReplacement\ForGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\MissingReplacement\ForGroupMessage;
use TRegx\CleanRegex\Replace\GroupMapper\StrategyFallbackAdapter;
use TRegx\CleanRegex\Replace\GroupMapper\IdentityMapper;
use TRegx\CleanRegex\Replace\GroupMapper\DictionaryMapper;
Expand Down
Expand Up @@ -2,7 +2,7 @@
namespace TRegx\CleanRegex\Replace\Map;

use TRegx\CleanRegex\Exception\CleanRegex\GroupNotMatchedException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Replace\GroupMapper\GroupMapper;
use TRegx\CleanRegex\Replace\NonReplaced\ComputedSubjectStrategy;
use TRegx\CleanRegex\Replace\NonReplaced\ConstantResultStrategy;
Expand Down
4 changes: 2 additions & 2 deletions src/TRegx/CleanRegex/Replace/NonReplaced/ThrowStrategy.php
Expand Up @@ -2,8 +2,8 @@
namespace TRegx\CleanRegex\Replace\NonReplaced;

use TRegx\CleanRegex\Exception\CleanRegex\InternalCleanRegexException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\InternalExceptionMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NotMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\InternalExceptionMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NotMatchedMessage;
use TRegx\CleanRegex\Internal\SignatureExceptionFactory;
use TRegx\CleanRegex\Internal\SubjectableImpl;

Expand Down
2 changes: 1 addition & 1 deletion src/TRegx/CleanRegex/Replace/ReplacePatternImpl.php
@@ -1,7 +1,7 @@
<?php
namespace TRegx\CleanRegex\Replace;

use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NonReplaced\NonMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NonReplaced\NonMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotReplacedException;
use TRegx\CleanRegex\Internal\InternalPattern;
use TRegx\CleanRegex\Replace\Map\ByReplacePattern;
Expand Down
4 changes: 2 additions & 2 deletions src/TRegx/CleanRegex/Replace/SpecificReplacePatternImpl.php
Expand Up @@ -2,7 +2,7 @@
namespace TRegx\CleanRegex\Replace;

use TRegx\CleanRegex\Exception\CleanRegex\MissingReplacementKeyException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\MissingReplacement\ForMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\MissingReplacement\ForMatchMessage;
use TRegx\CleanRegex\Internal\InternalPattern as Pattern;
use TRegx\CleanRegex\Internal\Match\Base\ApiBase;
use TRegx\CleanRegex\Internal\Match\UserData;
Expand Down Expand Up @@ -76,7 +76,7 @@ public function by(): ByReplacePattern
),
new ThrowStrategy(
MissingReplacementKeyException::class,
new ForMatchMessage()
new ForMatchMessage('')
)
);
}
Expand Down
Expand Up @@ -4,7 +4,7 @@
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use TRegx\CleanRegex\Exception\CleanRegex\GroupNotMatchedException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\GroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\GroupMessage;
use TRegx\CleanRegex\Internal\Factory\GroupExceptionFactory;
use TRegx\CleanRegex\Internal\Factory\NotMatchedOptionalWorker;
use TRegx\CleanRegex\Internal\Match\Details\Group\GroupDetails;
Expand Down
Expand Up @@ -4,7 +4,7 @@
use InvalidArgumentException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NonReplaced\NonMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NonReplaced\NonMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\NotReplacedException;
use TRegx\CleanRegex\Internal\InternalPattern;
use TRegx\CleanRegex\Replace\NonReplaced\ComputedSubjectStrategy;
Expand Down
Expand Up @@ -16,7 +16,7 @@
use Throwable;
use TRegx\CleanRegex\Exception\CleanRegex\ClassExpectedException;
use TRegx\CleanRegex\Exception\CleanRegex\NoSuitableConstructorException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\SubjectNotMatchedException;
use TRegx\CleanRegex\Internal\SignatureExceptionFactory;
use TRegx\CleanRegex\Internal\SubjectableImpl;
Expand Down Expand Up @@ -118,7 +118,7 @@ public function shouldInstantiate_withMessageAndSubjectParams()

// then
$this->assertInstanceOf(ClassWithTwoStringParamsConstructor::class, $exception);
$this->assertEquals(FirstMatchMessage::MESSAGE, $exception->getMessage());
$this->assertEquals('Expected to get first match, but subject was not matched', $exception->getMessage());
$this->assertEquals('my subject', $exception->getSubject());
}

Expand All @@ -136,7 +136,7 @@ public function shouldInstantiate_withMessageParam()

// then
$this->assertInstanceOf(ClassWithStringParamConstructor::class, $exception);
$this->assertEquals(FirstMatchMessage::MESSAGE, $exception->getMessage());
$this->assertEquals('Expected to get first match, but subject was not matched', $exception->getMessage());
}

/**
Expand Down Expand Up @@ -187,7 +187,7 @@ public function shouldInstantiate_withMessage(string $className)

// then
$this->assertInstanceOf($className, $exception);
$this->assertEquals(FirstMatchMessage::MESSAGE, $exception->getMessage());
$this->assertEquals('Expected to get first match, but subject was not matched', $exception->getMessage());
}

/**
Expand Down
Expand Up @@ -3,7 +3,7 @@

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Subject\FirstMatchMessage;
use TRegx\CleanRegex\Exception\CleanRegex\SubjectNotMatchedException;
use TRegx\CleanRegex\Internal\InternalPattern as Pattern;
use TRegx\CleanRegex\Match\Details\Match;
Expand Down Expand Up @@ -131,7 +131,7 @@ public function should_onNotMatchingSubject_throw_withMessage()

// then
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(FirstMatchMessage::MESSAGE);
$this->expectExceptionMessage('Expected to get first match, but subject was not matched');

// when
$pattern->forFirst('strrev')->orThrow(InvalidArgumentException::class);
Expand Down
Expand Up @@ -4,7 +4,7 @@
use PHPUnit\Framework\TestCase;
use Test\Feature\TRegx\CleanRegex\Replace\by\group\CustomException;
use TRegx\CleanRegex\Exception\CleanRegex\NonexistentGroupException;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\Group\ReplacementWithUnmatchedGroupMessage;
use TRegx\CleanRegex\Internal\InternalPattern;
use TRegx\CleanRegex\Internal\Match\Base\ApiBase;
use TRegx\CleanRegex\Internal\Match\UserData;
Expand Down
Expand Up @@ -3,7 +3,7 @@

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use TRegx\CleanRegex\Exception\CleanRegex\NotMatched\NonReplaced\NonMatchedMessage;
use TRegx\CleanRegex\Exception\CleanRegex\Messages\NonReplaced\NonMatchedMessage;

class ThrowStrategyTest extends TestCase
{
Expand Down

0 comments on commit fbf43f5

Please sign in to comment.