Debug mailer finished and debug messages removed:
[shipsimu.git] / application / ship-simu / main / personell / class_SimulatorPersonell.php
index 76d8ecfe433efcc5b8720cc4d05f5c7fdecd5fe3..1021c569e30606308eee49574cd76248211a482f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -82,7 +82,7 @@ class SimulatorPersonell extends BasePersonell {
                $personellInstance = new SimulatorPersonell();
 
                // Debug message
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] Es werden <strong>%d</strong> Personal bereitgestellt.<br />\n",
+               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] Es werden <strong>%d</strong> Personal bereitgestellt.",
                        __CLASS__,
                        __LINE__,
                        $amountPersonell
@@ -97,7 +97,7 @@ class SimulatorPersonell extends BasePersonell {
                }
 
                // Debug message
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->getDebugInstance()->output(sprintf("[%s:%d] <strong>%d</strong> Personal bereitgestellt.<br />\n",
+               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] <strong>%d</strong> Personal bereitgestellt.",
                        __CLASS__,
                        __LINE__,
                        $amountPersonell
@@ -122,16 +122,11 @@ class SimulatorPersonell extends BasePersonell {
         * Create a SimulatorPersonell object by loading the specified personell
         * list from an existing database backend
         *
-        * @param               $idNumber               The ID number (only right part) of the list
-        * @return      $personellInstance      An instance of
-        * @throws      InvalidIDFormatException                If the given id number
-        *                                                                      $idNumber is invalid
-        * @throws      NullPointerException            If a null pointer (instance)
-        *                                                                      has been returned.
-        * @throws      NoObjectException                       If a non-object has been
-        *                                                                      returned
-        * @throws      MissingMethodException          If a required method is missing
-        * @throws      MissingSimulatorIDException     If an ID number was not found
+        * @param       $idNumber                       The ID number (only right part) of the list
+        * @return      $personellInstance      An instance of this class
+        * @throws      InvalidIDFormatException        If the given id number
+        *                                                                              $idNumber is invalid
+        * @throws      MissingSimulatorIdException             If an ID number was not found
         */
        public final static function createSimulatorPersonellByID ($idNumber) {
                // Add the class name if it was not found
@@ -155,22 +150,10 @@ class SimulatorPersonell extends BasePersonell {
                // Get database instance
                $dbInstance = $personellInstance->getDatabaseInstance();
 
-               // Is this a valid database instance?
-               if (is_null($dbInstance)) {
-                       // No class returned
-                       throw new NullPointerException($personellInstance, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($dbInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($dbInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($dbInstance, 'isUniqueIdUsed')) {
-                       // Required method not found
-                       throw new MissingMethodException(array($dbInstance, 'isUniqueIdUsed'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Is the unique ID already used? Then it must be there!
                if (!$dbInstance->isUniqueIdUsed($tempID))  {
                        // Entry not found!
-                       throw new MissingSimulatorIDException(array($personellInstance, $idNumber), self::EXCEPTION_SIMULATOR_ID_INVALID);
+                       throw new MissingSimulatorIdException(array($personellInstance, $idNumber), self::EXCEPTION_SIMULATOR_ID_INVALID);
                }
 
                // Load the personell list and add it to this object
@@ -194,10 +177,6 @@ class SimulatorPersonell extends BasePersonell {
        // Create personell list
        public function createPersonellList () {
                if (is_null($this->personellList)) {
-                       if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Personell-Liste erstellt.<br />\n",
-                               __CLASS__,
-                               __LINE__
-                       ));
                        $this->personellList = new FrameworkArrayObject("FakedPersonellList");
                } else {
                        throw new PersonellListAlreadyCreatedException($this, self::EXCEPTION_DIMENSION_ARRAY_INVALID);
@@ -206,17 +185,13 @@ class SimulatorPersonell extends BasePersonell {
 
        // Remove the personell list
        private function removePersonellList () {
-               if (defined('DEBUG_PERSONELL')) $this->getDebugInstance()->output(sprintf("[%s:%d] Personell-Liste entfernt.<br />\n",
-                       __CLASS__,
-                       __LINE__
-               ));
                unset($this->personellList);
        }
 
        // Add new personell object to our list
        public function addRandomPersonell () {
                // Gender list...
-               $genders = array('M', 'F');
+               $genders = array("M", "F");
 
                // Create new personell members
                $personellInstance = new SimulatorPersonell();
@@ -251,7 +226,7 @@ class SimulatorPersonell extends BasePersonell {
 
                // The same (last) conditions?
                if (($serialized == $this->cacheCond) && (!is_null($this->cacheCond))) {
-                       if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Gecachte Liste wird verwendet.<br />\n",
+                       if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Gecachte Liste wird verwendet.",
                                __CLASS__,
                                __LINE__
                        ));
@@ -261,7 +236,7 @@ class SimulatorPersonell extends BasePersonell {
                }
 
                // Output debug message
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Personalliste wird nach Kriterien durchsucht...<br />\n",
+               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Personalliste wird nach Kriterien durchsucht...",
                        __CLASS__,
                        __LINE__
                ));
@@ -270,7 +245,7 @@ class SimulatorPersonell extends BasePersonell {
                $this->setCacheCond($serialized);
 
                // Create cached list
-               $this->setAllCacheList(new FrameworkArrayObject("FakedCacheList"));
+               $this->setAllCacheList(new FrameworkArrayObject('FakedCacheList'));
 
                // Search all unemployed personells
                for ($idx = $this->personellList->getIterator(); $idx->valid(); $idx->next()) {
@@ -300,11 +275,6 @@ class SimulatorPersonell extends BasePersonell {
         * @return      $count  Amount of unemployed personell
         */
        public final function getAllUnemployed () {
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Es werden alle erwerbslosen Personen gesucht.<br />\n",
-                       __CLASS__,
-                       __LINE__
-               ));
-
                // Get a temporary list
                $list = $this->getSpecialPersonellList(false);
 
@@ -318,11 +288,6 @@ class SimulatorPersonell extends BasePersonell {
         * @return      void
         */
        private function removeCache () {
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Cache-Attribute entfernt.<br />\n",
-                       __CLASS__,
-                       __LINE__
-               ));
-
                // Remove cache data
                unset($this->cacheList);
                unset($this->cacheCond);
@@ -354,10 +319,6 @@ class SimulatorPersonell extends BasePersonell {
         * @return      void
         */
        public function resetCache () {
-               if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->getDebugInstance()->output(sprintf("[%s:%d] Cache-Liste zur&uuml;ckgesetzt.<br />\n",
-                       __CLASS__,
-                       __LINE__
-               ));
                $this->setAllCacheList(null);
                $this->setCacheCond("");
        }
@@ -366,10 +327,11 @@ class SimulatorPersonell extends BasePersonell {
         * Getter for surname. If no surname is set then default surnames are set
         * for male and female personells.
         *
-        * @return      $surname                The personell' surname
+        * @return      $surname        The personell' surname
         */
        public final function getSurname () {
                $surname = parent::getSurname();
+
                // Make sure every one has a surname...
                if (empty($surname)) {
                        if ($this->isMale()) {
@@ -382,7 +344,9 @@ class SimulatorPersonell extends BasePersonell {
 
                        // Set typical family name
                        parent::setFamily("Smith");
-               }
+               } // END - if
+
+               // Return surname
                return $surname;
        }
 
@@ -398,22 +362,19 @@ class SimulatorPersonell extends BasePersonell {
        /**
         * Loads the mostly pre-cached personell list
         *
-        * @param               $idNumber               The ID number we shall use for looking up
+        * @param       $idNumber       The ID number we shall use for looking up
         *                                              the right data.
         * @return      void
         * @throws      ContainerItemIsNullException    If a container item is null
         * @throws      ContainerItemIsNoArrayException If a container item is
-        *                                                                              not an array
+        *                                                                                      not an array
         * @throws      ContainerMaybeDamagedException  If the container item
-        *                                                                              is missing the indexes
-        *                                                                              'name' and/or 'value'
-        * @see         SerializationContainer  A special container class which
-        *                                                              helps storing only some attributes
-        *                                                              of a class.
+        *                                                                                      is missing the indexes
+        *                                                                                      'name' and/or 'value'
         */
        public function loadPersonellList ($idNumber) {
                // Cleared because old code
-               $this->partialStub("Clear because of old lost code was usaged.");
+               $this->partialStub("Cleared because old lost code was used.");
        }
 }