| 1 | <?php |
||
| 12 | class MailResult implements ResultInterface |
||
| 13 | { |
||
| 14 | const DEFAULT_MESSAGE = 'Success!!'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var boolean |
||
| 18 | */ |
||
| 19 | private $valid; |
||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $message; |
||
| 24 | /** |
||
| 25 | * @var Exception |
||
| 26 | */ |
||
| 27 | private $exception; |
||
| 28 | |||
| 29 | 17 | public function __construct($valid = true, $message = self::DEFAULT_MESSAGE, $exception = null) |
|
| 30 | { |
||
| 31 | 17 | $this->valid = (bool) $valid; |
|
| 32 | 17 | $this->message = $message; |
|
| 33 | 17 | $this->exception = $exception; |
|
| 34 | 17 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Returns error message when an error occurs |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | 5 | public function getMessage() |
|
| 41 | { |
||
| 42 | 5 | return $this->message; |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Tells if the MailService that produced this result was properly sent |
||
| 47 | * @return bool |
||
| 48 | */ |
||
| 49 | 11 | public function isValid() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Tells if this Result has an exception. Usually only non-valid result should wrap an exception |
||
| 56 | * @return bool |
||
| 57 | */ |
||
| 58 | 3 | public function hasException() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * Returns the exception wraped by this Result |
||
| 65 | * @return \Exception |
||
| 66 | */ |
||
| 67 | 3 | public function getException() |
|
| 71 | } |
||
| 72 |