3232
3333namespace GlpiPlugin \Carbon ;
3434
35+ use RuntimeException ;
3536use Config ;
3637use DBmysql ;
3738use DirectoryIterator ;
@@ -112,7 +113,7 @@ public function install(array $args = []): bool
112113
113114 try {
114115 $ DB ->runFile ($ dbFile );
115- } catch (\ RuntimeException $ e ) {
116+ } catch (RuntimeException $ e ) {
116117 $ this ->migration ->addWarningMessage ("Error creating tables : " . $ e ->getMessage ());
117118 return false ;
118119 }
@@ -150,7 +151,7 @@ public function upgrade(string $from_version, array $args = []): bool
150151 $ current_version = $ matches [1 ];
151152 if (version_compare ($ db_version , $ current_version ) > 0 ) {
152153 // database more recent than current version
153- $ e = new \ RuntimeException (sprintf (
154+ $ e = new RuntimeException (sprintf (
154155 'Database of the plugin %s is more recent than the installed version %s. ' ,
155156 $ db_version ,
156157 $ current_version
@@ -167,19 +168,19 @@ public function upgrade(string $from_version, array $args = []): bool
167168 // Check the version os SEMVER compliant
168169 $ regex = '!^ ' . self ::SEMVER_REGEX . '$! ' ;
169170 if (preg_match ($ regex , $ this ->force_upgrade_from_version ) !== 1 ) {
170- $ e = new \ RuntimeException ('Invalid start version for upgrade. ' );
171+ $ e = new RuntimeException ('Invalid start version for upgrade. ' );
171172 trigger_error ($ e ->getMessage (), E_USER_WARNING );
172173 throw $ e ;
173174 }
174175 if (version_compare ($ this ->force_upgrade_from_version , $ oldest_upgradable_version ) < 0 ) {
175- $ e = new \ RuntimeException ('Upgrade is not supported before ' . $ this ->force_upgrade_from_version . '. ' );
176+ $ e = new RuntimeException ('Upgrade is not supported before ' . $ this ->force_upgrade_from_version . '. ' );
176177 trigger_error ($ e ->getMessage (), E_USER_WARNING );
177178 throw $ e ;
178179 }
179180 }
180181 } else {
181182 if (version_compare ($ from_version , $ oldest_upgradable_version , 'lt ' )) {
182- $ e = new \ RuntimeException ("Upgrade is not supported before $ oldest_upgradable_version! " );
183+ $ e = new RuntimeException ("Upgrade is not supported before $ oldest_upgradable_version! " );
183184 trigger_error ($ e ->getMessage (), E_USER_WARNING );
184185 throw $ e ;
185186 }
@@ -288,7 +289,7 @@ public static function getOrCreateSource(string $name, int $fallback_level = 1,
288289 'name ' => $ name ,
289290 ]);
290291 if ($ source ->isNewItem ()) {
291- throw new \ RuntimeException ("Failed to create carbon intensity source ' $ name' in DB " );
292+ throw new RuntimeException ("Failed to create carbon intensity source ' $ name' in DB " );
292293 }
293294 return $ source ->getID ();
294295 }
@@ -310,7 +311,7 @@ public static function getOrCreateZone(string $name, int $source_id): int
310311 ]);
311312 $ zone ->getFromDBByCrit (['name ' => $ name ]);
312313 if ($ zone ->isNewItem ()) {
313- throw new \ RuntimeException ("Failed to create zone ' $ name' in DB " );
314+ throw new RuntimeException ("Failed to create zone ' $ name' in DB " );
314315 }
315316 return $ zone ->getID ();
316317 }
0 commit comments