From 8b7ff617382ba5e00ace36cfb614979caff8892c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 17 Aug 2017 12:57:37 +0200 Subject: [PATCH] feat(option) Update the `unwrap` default message. As @mathroc suggested in https://github.com/hoaproject/Option/issues/10, the panic message should not reflect an implementation detail but must reflect the semantics of the operation. --- Option.php | 2 +- Test/Unit/Option.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Option.php b/Option.php index 3e8107f..fd5dd78 100644 --- a/Option.php +++ b/Option.php @@ -211,7 +211,7 @@ public function expect(string $errorMessage) */ public function unwrap() { - return $this->expect('Unwrap a null value.'); + return $this->expect('Called `' . __METHOD__ . '` on a none value.'); } /** diff --git a/Test/Unit/Option.php b/Test/Unit/Option.php index 513d7a4..572eb91 100644 --- a/Test/Unit/Option.php +++ b/Test/Unit/Option.php @@ -178,8 +178,8 @@ public function case_none_unwrap() ->exception(function () use ($option) { $option->unwrap(); }) - ->isInstanceOf(RuntimeException::class) - ->hasMessage('Unwrap a null value.'); + ->isInstanceOf(RuntimeException::class) + ->hasMessage('Called `' . SUT::class . '::unwrap` on a none value.'); } public function case_some_unwrap_or()