Repository: BenSampo/laravel-enum (php)

Issue:
getDescription() throws error if value does not exist in v5
In v4, calling `getDescription()` with an incorrect value returns an empty string, but in v5 it throws an Error.

```
class MyEnum extends Enum {
   const MyValue = 'MyValue';
}
var_dump(MyEnum::getDescription('no'));
```

```
PHP Fatal error:  Uncaught Error: Call to a member function getAttributes() on bool in /project/vendor/bensampo/laravel-enum/src/Enum.php:406
Stack trace:
#0 /project/vendor/bensampo/laravel-enum/src/Enum.php(369): BenSampo\Enum\Enum::getAttributeDescription('no')
#1 /project/foo.php(12): BenSampo\Enum\Enum::getDescription('no')
#2 {main}
  thrown in /project/vendor/bensampo/laravel-enum/src/Enum.php on line 406
```

Pull request description:
Fix getAttributeDescription() error
- [x] Added or updated tests
- [ ] Added or updated the [README.md](../README.md)
- [ ] Detailed changes in the [CHANGELOG.md](../CHANGELOG.md) unreleased section

**Related Issue/Intent**
Resolves #263

**Changes**
Calling `MyEnum::getDescription($value)` with an invalid value now returns an empty string, rather than throwing an error. This is in line with the behaviour in v4.

**Breaking changes**
N/A


Patch:
diff --git a/src/Enum.php b/src/Enum.php
index eefff9a..0e0244d 100644
--- a/src/Enum.php
+++ b/src/Enum.php
@@ -403,6 +403,9 @@ abstract class Enum implements EnumContract, Castable, Arrayable, JsonSerializab
         $reflection = self::getReflection();
         $constantName = static::getKey($value);
         $constReflection = $reflection->getReflectionConstant($constantName);
+        if ($constReflection === false) {
+            return null;
+        }
         $descriptionAttributes = $constReflection->getAttributes(Description::class);
 
         if (count($descriptionAttributes) === 1) {


Test patch:
diff --git a/tests/EnumAttributeDescriptionTest.php b/tests/EnumAttributeDescriptionTest.php
index fd3bc38..1784ef1 100644
--- a/tests/EnumAttributeDescriptionTest.php
+++ b/tests/EnumAttributeDescriptionTest.php
@@ -25,4 +25,9 @@ class EnumAttributeDescriptionTest extends TestCase
 
         DescriptionFromAttribute::InvalidCaseWithMultipleDescriptions()->description;
     }
+
+    public function test_an_exception_is_not_thrown_when_accessing_a_description_for_an_invalid_value()
+    {
+        $this->assertSame('', DescriptionFromAttribute::getDescription('invalid'));
+    }
 }