From 3b6cc070b7a40b477e1edfe5bb0fc0e2d3f4aa4f Mon Sep 17 00:00:00 2001 From: ignaszak Date: Wed, 23 Mar 2016 20:59:02 +0100 Subject: [PATCH] Add RegistryException --- src/Registry.php | 14 +++++++------- src/RegistryException.php | 21 +++++++++++++++++++++ src/RegistryFactory.php | 4 ++-- tests/RegistryFactoryTest.php | 2 +- tests/RegistryTest.php | 8 ++++---- tests/Scope/FileRegistryTest.php | 4 ++-- 6 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 src/RegistryException.php diff --git a/src/Registry.php b/src/Registry.php index fa97f0c..cd14297 100644 --- a/src/Registry.php +++ b/src/Registry.php @@ -61,7 +61,7 @@ public function get(string $name) /** * @param string $name * @return object - * @throws Exception + * @throws RegistryException */ public function register(string $name) { @@ -84,7 +84,7 @@ public function remove(string $name): bool /** * @param string $name * @return boolean - * @throws Exception + * @throws RegistryException */ public function reload(string $name): bool { @@ -92,35 +92,35 @@ public function reload(string $name): bool $className = get_class($this->get($name)); return $this->set($name, new $className); } else { - throw new \RuntimeException("Class '$name' not registered"); + throw new RegistryException("Class '$name' not registered"); } } /** * @param object $value * @return boolean - * @throws Exception + * @throws RegistryException */ private function isObject($value): bool { if (is_object($value)) { return true; } else { - throw new \RuntimeException('Object not exists'); + throw new RegistryException('Object not exists'); } } /** * @param string $name * @return boolean - * @throws Exception + * @throws RegistryException */ private function classExists(string $name): bool { if (class_exists($name)) { return true; } else { - throw new \RuntimeException("Class '$name' not exists"); + throw new RegistryException("Class '$name' not exists"); } } } diff --git a/src/RegistryException.php b/src/RegistryException.php new file mode 100644 index 0000000..f08c476 --- /dev/null +++ b/src/RegistryException.php @@ -0,0 +1,21 @@ +