add docblocks to all files, classes, methods and variables
[bdrem.git] / src / bdrem / Config.php
index 57d0cfd7d1995527cb8163b3bb0355756071e417..f586ed37c25e88ae0c0bd08d683b62ef07d0cb19 100644 (file)
 <?php
 <?php
+/**
+ * Part of bdrem
+ *
+ * PHP version 5
+ *
+ * @category  Tools
+ * @package   Bdrem
+ * @author    Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link      http://cweiske.de/bdrem.htm
+ */
 namespace bdrem;
 
 namespace bdrem;
 
+/**
+ * Configuration options for bdrem
+ *
+ * @category  Tools
+ * @package   Bdrem
+ * @author    Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @version   Release: @package_version@
+ * @link      http://cweiske.de/bdrem.htm
+ */
 class Config
 {
 class Config
 {
+    /**
+     * Current date, YYYY-MM-DD
+     * @var string
+     */
     public $date;
     public $date;
+
+    /**
+     * Days to show before $date
+     * @var integer
+     */
     public $daysPrev;
     public $daysPrev;
+
+    /**
+     * Days to show after $date
+     * @var integer
+     */
     public $daysNext;
     public $daysNext;
+
+    /**
+     * Locale to render the dates in, e.g. "de_DE.UTF-8"
+     * @var string
+     */
     public $locale;
     public $locale;
+
+    /**
+     * Renderer name to use (e.g. "console")
+     * @var string
+     */
     public $renderer;
     public $renderer;
+
+    /**
+     * Event source configuration.
+     * - First value is source name ("Ldap", "Sql")
+     * - Second value is the source configuration
+     * @var array
+     */
     public $source;
     public $source;
+
+    /**
+     * Do not output anything if there are no events to show
+     * @var boolean
+     */
     public $stopOnEmpty;
 
     public $stopOnEmpty;
 
+    /**
+     * List of config file paths that were tried to load
+     * @var array
+     */
     public $cfgFiles = array();
     public $cfgFiles = array();
+
+    /**
+     * If a configuration file could be found
+     * @var boolean
+     */
     public $cfgFileExists;
 
 
 
     public $cfgFileExists;
 
 
 
+    /**
+     * Init configuration file path loading
+     */
     public function __construct()
     {
         $this->loadConfigFilePaths();
     }
 
     public function __construct()
     {
         $this->loadConfigFilePaths();
     }
 
+    /**
+     * Load the configuration from the first configuration file found.
+     *
+     * @return void
+     */
     public function load()
     {
         foreach ($this->cfgFiles as $file) {
     public function load()
     {
         foreach ($this->cfgFiles as $file) {
@@ -32,6 +108,11 @@ class Config
         $this->cfgFileExists = false;
     }
 
         $this->cfgFileExists = false;
     }
 
+    /**
+     * Load possible configuration file paths into $this->cfgFiles.
+     *
+     * @return void
+     */
     protected function loadConfigFilePaths()
     {
         $pharFile = \Phar::running();
     protected function loadConfigFilePaths()
     {
         $pharFile = \Phar::running();
@@ -47,6 +128,13 @@ class Config
         $this->cfgFiles[] = '/etc/bdrem.php';
     }
 
         $this->cfgFiles[] = '/etc/bdrem.php';
     }
 
+    /**
+     * Load a single configuration file and set the config class variables
+     *
+     * @param string $filename Configuration file path
+     *
+     * @return void
+     */
     protected function loadFile($filename)
     {
         include $filename;
     protected function loadFile($filename)
     {
         include $filename;
@@ -58,6 +146,12 @@ class Config
         }
     }
 
         }
     }
 
+    /**
+     * Load a event source from $this->source.
+     * Class name has to be \bdrem\Source_$source
+     *
+     * @return object Source object
+     */
     public function loadSource()
     {
         if ($this->source === null) {
     public function loadSource()
     {
         if ($this->source === null) {
@@ -70,6 +164,13 @@ class Config
         return new $class($settings[0]);
     }
 
         return new $class($settings[0]);
     }
 
+    /**
+     * Set the current date
+     *
+     * @param string $date Date in any format
+     *
+     * @return void
+     */
     public function setDate($date)
     {
         if ($date === null) {
     public function setDate($date)
     {
         if ($date === null) {
@@ -80,6 +181,15 @@ class Config
         }
     }
 
         }
     }
 
+    /**
+     * Get a configuration variable
+     *
+     * @param string $varname Configuration variable name
+     * @param string $default Default value in case the variable is not set
+     *                        or is empty
+     *
+     * @return mixed Configuration value or default
+     */
     public function get($varname, $default = '')
     {
         if (!isset($this->$varname) || $this->$varname == '') {
     public function get($varname, $default = '')
     {
         if (!isset($this->$varname) || $this->$varname == '') {