File tree Expand file tree Collapse file tree 4 files changed +12
-2
lines changed
Expand file tree Collapse file tree 4 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 22 "name" : " byscripts/static-entity" ,
33 "type" : " library" ,
44 "description" : " Provide some kind of static entities" ,
5- "minimum-stability" : " dev" ,
65 "license" : " MIT" ,
76 "authors" : [
87 {
Original file line number Diff line number Diff line change @@ -131,7 +131,9 @@ public function hasId($id)
131131 */
132132 public function convertToId ($ staticEntity )
133133 {
134- if ($ staticEntity instanceof StaticEntity) {
134+ if (empty ($ staticEntity )) {
135+ return null ;
136+ } elseif ($ staticEntity instanceof StaticEntity) {
135137 return $ staticEntity ->getId ();
136138 } elseif (!$ this ->hasId ($ staticEntity )) {
137139 throw new \Exception (
Original file line number Diff line number Diff line change @@ -98,7 +98,12 @@ public function testToId()
9898
9999 $ this ->assertEquals ('mr ' , $ builder ->convertToId ($ civility ));
100100 $ this ->assertEquals ('mr ' , $ builder ->convertToId ('mr ' ));
101+ }
101102
103+ public function testEmptyToId ()
104+ {
105+ $ builder = new StaticEntityManager ('\Byscripts\StaticEntity\Tests\Fixtures\Civility ' );
106+ $ this ->assertNull ($ builder ->convertToId ("" ));
102107 }
103108
104109 /**
Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ public function testToId()
8585
8686 $ this ->assertEquals ('mr ' , Civility::toId ($ civility ));
8787 $ this ->assertEquals ('mr ' , Civility::toId ('mr ' ));
88+ }
8889
90+ public function testEmptyToId ()
91+ {
92+ $ this ->assertNull (Civility::toId ("" ));
8993 }
9094
9195 /**
You can’t perform that action at this time.
0 commit comments