File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 33namespace Coderflex \LaravelPresenter \Exceptions ;
44
55use Exception ;
6+ use Illuminate \Database \Eloquent \Model ;
67
78class PresenterException extends Exception
89{
@@ -19,4 +20,18 @@ class PresenterException extends Exception
1920 * @var int
2021 */
2122 protected $ code = 500 ;
23+
24+ /**
25+ * Method for Presenter Implementation absence on the model
26+ * @param Model $model
27+ * @return self
28+ */
29+ public static function interfaceNotImplemented (Model $ model ): self
30+ {
31+ return new self ((__ (':model should implements :interface interface ' , [
32+ 'model ' => get_class ($ model ),
33+ 'interface ' => '\Coderflex\LaravelPresenter\Concerns\CanPresent ' ,
34+ ])
35+ ));
36+ }
2237}
Original file line number Diff line number Diff line change @@ -17,12 +17,7 @@ abstract class Presenter
1717 public function __construct (Model $ model )
1818 {
1919 if (! $ model instanceof \Coderflex \LaravelPresenter \Concerns \CanPresent) {
20- throw new PresenterException (
21- __ (':model should implements :interface interface ' , [
22- 'model ' => get_class ($ model ),
23- 'interface ' => '\Coderflex\LaravelPresenter\Concerns\CanPresent ' ,
24- ])
25- );
20+ throw PresenterException::interfaceNotImplemented ($ model );
2621 }
2722
2823 $ this ->model = $ model ;
You can’t perform that action at this time.
0 commit comments