Skip to content

Commit 5cd0a8f

Browse files
author
Mark Challoner
committed
Rename InvalidReturnException to InvalidConditionException. Address style violations.
1 parent 5db5f55 commit 5cd0a8f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/InvalidReturnException.php renamed to src/InvalidConditionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* The exception that is thrown when an invalid return value from a callback is specified.
66
*/
7-
class InvalidReturnException extends \RuntimeException
7+
class InvalidConditionException extends \RuntimeException
88
{
99
// Intentionally empty.
1010
}

src/Strategy/IfElse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace ScriptFUSION\Mapper\Strategy;
33

4-
use ScriptFUSION\Mapper\InvalidReturnException;
4+
use ScriptFUSION\Mapper\InvalidConditionException;
55
use ScriptFUSION\Mapper\Mapping;
66

77
/**
@@ -38,7 +38,7 @@ public function __construct(callable $condition, $if, $else = null)
3838
* @param mixed $data
3939
* @param mixed $context
4040
*
41-
* @throws InvalidReturnException
41+
* @throws InvalidConditionException
4242
*
4343
* @return mixed
4444
*/
@@ -47,7 +47,7 @@ public function __invoke($data, $context = null)
4747
$return = call_user_func($this->condition, $data, $context);
4848

4949
if (!is_bool($return)) {
50-
throw new InvalidReturnException('Invalid return from condition: must be of type boolean.');
50+
throw new InvalidConditionException('Invalid return from condition: must be of type boolean.');
5151
}
5252

5353
if ($return === true) {

test/Functional/DocumentationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ function ($data) {
236236
return false;
237237
}
238238
}
239+
239240
return true;
240241
},
241242
true,
@@ -254,6 +255,7 @@ function ($data) {
254255
return false;
255256
}
256257
}
258+
257259
return true;
258260
},
259261
true,

test/Integration/Mapper/Strategy/IfElseTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
namespace ScriptFUSIONTest\Integration\Mapper\Strategy;
33

44
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
5-
use ScriptFUSION\Mapper\InvalidReturnException;
5+
use ScriptFUSION\Mapper\InvalidConditionException;
66
use ScriptFUSION\Mapper\Mapper;
7-
use ScriptFUSION\Mapper\Strategy\Exists;
87
use ScriptFUSION\Mapper\Strategy\IfElse;
9-
use ScriptFUSION\Mapper\Strategy\Strategy;
108

119
final class IfElseTest extends \PHPUnit_Framework_TestCase
1210
{
@@ -16,7 +14,7 @@ final class IfElseTest extends \PHPUnit_Framework_TestCase
1614

1715
public function setUp()
1816
{
19-
$this->condition = function($data) {
17+
$this->condition = function ($data) {
2018
return array_key_exists('baz', $data) && $data['baz'] === 'qux';
2119
};
2220
}
@@ -41,7 +39,7 @@ public function testOnlyIf()
4139

4240
public function testStrictness()
4341
{
44-
$this->setExpectedException(InvalidReturnException::class);
42+
$this->setExpectedException(InvalidConditionException::class);
4543

4644
$ifElse = (new IfElse(
4745
function () {

0 commit comments

Comments
 (0)