File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,24 @@ class ResourceAlreadyExistsException extends Exception
1010 public function __construct (
1111 protected string $ filePath ,
1212 ) {
13+ $ entity = $ this ->getEntity ();
14+
15+ $ filePath = $ this ->getFilePath ();
16+
17+ parent ::__construct ("Cannot create {$ entity } cause it already exists. Remove {$ filePath } and run command again. " );
18+ }
19+
20+ protected function getEntity (): string
21+ {
1322 $ entity = Str::afterLast ($ this ->filePath , '/ ' );
14- $ entity = Str::before ($ entity , '.php ' );
1523
16- parent ::__construct ("Cannot create {$ entity } cause it already exists. Remove {$ this ->filePath } and run command again. " );
24+ return Str::before ($ entity , '.php ' );
25+ }
26+
27+ protected function getFilePath (): string
28+ {
29+ $ filePath = realpath ($ this ->filePath );
30+
31+ return empty ($ filePath ) ? $ this ->filePath : "{$ filePath }:1 " ;
1732 }
1833}
Original file line number Diff line number Diff line change 77use RonasIT \Support \Events \WarningEvent ;
88use RonasIT \Support \Exceptions \CircularRelationsFoundedException ;
99use RonasIT \Support \Exceptions \ClassNotExistsException ;
10+ use RonasIT \Support \Exceptions \ResourceAlreadyExistsException ;
1011use RonasIT \Support \Generators \TestsGenerator ;
1112use RonasIT \Support \Tests \Support \Test \TestMockTrait ;
1213
You can’t perform that action at this time.
0 commit comments