@@ -38,6 +38,9 @@ class Report
3838 /** @var string */
3939 private $ applicationPath ;
4040
41+ /** @var ?string */
42+ private $ applicationVersion ;
43+
4144 /** @var array */
4245 private $ userProvidedContext = [];
4346
@@ -62,16 +65,21 @@ class Report
6265 /** @var string */
6366 private $ groupBy ;
6467
65- public static function createForThrowable (Throwable $ throwable , ContextInterface $ context , ?string $ applicationPath = null ): self
66- {
68+ public static function createForThrowable (
69+ Throwable $ throwable ,
70+ ContextInterface $ context ,
71+ ?string $ applicationPath = null ,
72+ ?string $ version = null
73+ ): self {
6774 return (new static ())
6875 ->setApplicationPath ($ applicationPath )
6976 ->throwable ($ throwable )
7077 ->useContext ($ context )
7178 ->exceptionClass (self ::getClassForThrowable ($ throwable ))
7279 ->message ($ throwable ->getMessage ())
7380 ->stackTrace (Stacktrace::createForThrowable ($ throwable , $ applicationPath ))
74- ->exceptionContext ($ throwable );
81+ ->exceptionContext ($ throwable )
82+ ->setApplicationVersion ($ version );
7583 }
7684
7785 protected static function getClassForThrowable (Throwable $ throwable ): string
@@ -193,6 +201,18 @@ public function getApplicationPath(): ?string
193201 return $ this ->applicationPath ;
194202 }
195203
204+ public function setApplicationVersion (?string $ applicationVersion )
205+ {
206+ $ this ->applicationVersion = $ applicationVersion ;
207+
208+ return $ this ;
209+ }
210+
211+ public function getApplicationVersion (): ?string
212+ {
213+ return $ this ->applicationVersion ;
214+ }
215+
196216 public function view (?View $ view )
197217 {
198218 $ this ->view = $ view ;
@@ -273,6 +293,7 @@ public function toArray()
273293 'message_level ' => $ this ->messageLevel ,
274294 'open_frame_index ' => $ this ->openFrameIndex ,
275295 'application_path ' => $ this ->applicationPath ,
296+ 'application_version ' => $ this ->applicationVersion ,
276297 ];
277298 }
278299}
0 commit comments