]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Move config exception to dedicated classes with proper namespace 794/head
authorArthurHoaro <arthur@hoa.ro>
Wed, 8 Mar 2017 19:28:33 +0000 (20:28 +0100)
committerArthurHoaro <arthur@hoa.ro>
Thu, 9 Mar 2017 18:16:42 +0000 (19:16 +0100)
application/config/ConfigManager.php
application/config/exception/MissingFieldConfigException.php [new file with mode: 0644]
application/config/exception/UnauthorizedConfigException.php [new file with mode: 0644]
tests/config/ConfigManagerTest.php

index 679a75b3bf2523eda94f9ba52b04edb84d48c717..f2097410364db285236fdd5013bcfa8729882e35 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 namespace Shaarli\Config;
 
+use Shaarli\Config\Exception\MissingFieldConfigException;
+use Shaarli\Config\Exception\UnauthorizedConfigException;
+
 /**
  * Class ConfigManager
  *
@@ -358,36 +361,3 @@ class ConfigManager
         $this->configIO = $configIO;
     }
 }
-
-/**
- * Exception used if a mandatory field is missing in given configuration.
- */
-class MissingFieldConfigException extends \Exception
-{
-    public $field;
-
-    /**
-     * Construct exception.
-     *
-     * @param string $field field name missing.
-     */
-    public function __construct($field)
-    {
-        $this->field = $field;
-        $this->message = 'Configuration value is required for '. $this->field;
-    }
-}
-
-/**
- * Exception used if an unauthorized attempt to edit configuration has been made.
- */
-class UnauthorizedConfigException extends \Exception
-{
-    /**
-     * Construct exception.
-     */
-    public function __construct()
-    {
-        $this->message = 'You are not authorized to alter config.';
-    }
-}
diff --git a/application/config/exception/MissingFieldConfigException.php b/application/config/exception/MissingFieldConfigException.php
new file mode 100644 (file)
index 0000000..6346c6a
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+
+
+namespace Shaarli\Config\Exception;
+
+/**
+ * Exception used if a mandatory field is missing in given configuration.
+ */
+class MissingFieldConfigException extends \Exception
+{
+    public $field;
+
+    /**
+     * Construct exception.
+     *
+     * @param string $field field name missing.
+     */
+    public function __construct($field)
+    {
+        $this->field = $field;
+        $this->message = 'Configuration value is required for '. $this->field;
+    }
+}
diff --git a/application/config/exception/UnauthorizedConfigException.php b/application/config/exception/UnauthorizedConfigException.php
new file mode 100644 (file)
index 0000000..79672c1
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+
+namespace Shaarli\Config\Exception;
+
+/**
+ * Exception used if an unauthorized attempt to edit configuration has been made.
+ */
+class UnauthorizedConfigException extends \Exception
+{
+    /**
+     * Construct exception.
+     */
+    public function __construct()
+    {
+        $this->message = 'You are not authorized to alter config.';
+    }
+}
index b81be5b66064c845ea6aafba3defb79210bb8c24..1ec447b23aeab9bfbe31b847e9731cfa780db617 100644 (file)
@@ -106,7 +106,7 @@ class ConfigManagerTest extends \PHPUnit_Framework_TestCase
     /**
      * Try to write the config without mandatory parameter (e.g. 'login').
      *
-     * @expectedException Shaarli\Config\MissingFieldConfigException
+     * @expectedException Shaarli\Config\Exception\MissingFieldConfigException
      */
     public function testWriteMissingParameter()
     {