Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 84ce14f

Browse files
author
Petr Knap
committed
OutOfRangeException renamed to EnumNotFoundException
1 parent 7641dcc commit 84ce14f

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/Enum/AbstractEnum.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
namespace PetrKnap\Php\Enum;
44

5-
use PetrKnap\Php\Enum\Exception\EnumException;
6-
use PetrKnap\Php\Enum\Exception\OutOfRangeException;
5+
use PetrKnap\Php\Enum\Exception\EnumNotFoundException;
76

87
/**
98
* Abstract enum object
@@ -37,7 +36,6 @@ abstract class AbstractEnum
3736

3837
/**
3938
* @param string $memberName
40-
* @throws EnumException
4139
*/
4240
protected function __construct($memberName)
4341
{
@@ -140,12 +138,12 @@ private function exists($memberName)
140138
/**
141139
* @param string $memberName
142140
* @return mixed
143-
* @throws EnumException
141+
* @throws EnumNotFoundException
144142
*/
145143
private function get($memberName)
146144
{
147145
if (!$this->exists($memberName)) {
148-
throw new OutOfRangeException(
146+
throw new EnumNotFoundException(
149147
sprintf(
150148
"%s does not exist in %s",
151149
$memberName,
@@ -160,7 +158,7 @@ private function get($memberName)
160158
/**
161159
* @param mixed $value
162160
* @return self
163-
* @throws EnumException
161+
* @throws EnumNotFoundException
164162
*/
165163
public static function findByValue($value)
166164
{
@@ -169,7 +167,7 @@ public static function findByValue($value)
169167
return self::__callStatic($n, []);
170168
}
171169
}
172-
throw new OutOfRangeException(
170+
throw new EnumNotFoundException(
173171
sprintf(
174172
"Value not found in %s",
175173
get_called_class()

src/Enum/Exception/OutOfRangeException.php renamed to src/Enum/Exception/EnumNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PetrKnap\Php\Enum\Exception;
44

5-
class OutOfRangeException extends EnumException
5+
class EnumNotFoundException extends EnumException
66
{
77
// Empty class
88
}

tests/Enum/EnumTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PetrKnap\Php\Enum\Test;
44

5-
use PetrKnap\Php\Enum\Exception\OutOfRangeException;
5+
use PetrKnap\Php\Enum\Exception\EnumNotFoundException;
66
use PetrKnap\Php\Enum\Test\EnumTest\MyBoolean;
77

88
class EnumTest extends \PHPUnit_Framework_TestCase
@@ -26,7 +26,7 @@ public function dataCallStaticsWorks()
2626
return [
2727
["MY_TRUE", 1],
2828
["MY_FALSE", 2],
29-
["MY_NULL", new OutOfRangeException()]
29+
["MY_NULL", new EnumNotFoundException()]
3030
];
3131
}
3232

@@ -49,7 +49,7 @@ public function dataFindByValueWorks()
4949
return [
5050
[1, MyBoolean::MY_TRUE()],
5151
[2, MyBoolean::MY_FALSE()],
52-
[3, new OutOfRangeException()]
52+
[3, new EnumNotFoundException()]
5353
];
5454
}
5555

0 commit comments

Comments
 (0)