]> git.mxchange.org Git - shipsimu.git/commitdiff
Unneccessary sanity checks removed
authorRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 13:57:33 +0000 (13:57 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 24 Jun 2008 13:57:33 +0000 (13:57 +0000)
13 files changed:
.gitattributes
application/selector/class_ApplicationSelector.php
application/ship-simu/exceptions/class_MissingSimulatorIDException.php [deleted file]
application/ship-simu/exceptions/class_MissingSimulatorIdException.php [new file with mode: 0644]
application/ship-simu/interfaces/class_Customer.php
application/ship-simu/main/class_WorksContract.php
application/ship-simu/main/personell/class_SimulatorPersonell.php
inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php
inc/classes/interfaces/io/file/class_FileInputStreamer.php
inc/classes/interfaces/io/file/class_FileOutputStreamer.php
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/middleware/debug/class_DebugMiddleware.php
inc/classes/middleware/io/class_FileIoHandler.php

index d5934558a5aace417f9f4d76edc75790cbe0f592..09c7448a002383a3e14c765a56feee7b2a756f1d 100644 (file)
@@ -30,7 +30,7 @@ application/ship-simu/exceptions/class_InvalidContractPartnerException.php -text
 application/ship-simu/exceptions/class_InvalidIDFormatException.php -text
 application/ship-simu/exceptions/class_ItemNotInPriceListException.php -text
 application/ship-simu/exceptions/class_ItemNotTradeableException.php -text
-application/ship-simu/exceptions/class_MissingSimulatorIDException.php -text
+application/ship-simu/exceptions/class_MissingSimulatorIdException.php -text
 application/ship-simu/exceptions/class_MotorShipMismatchException.php -text
 application/ship-simu/exceptions/class_NoShipyardsConstructedException.php -text
 application/ship-simu/exceptions/class_PersonellListAlreadyCreatedException.php -text
index be289bf93f7e7cf9f467725f104bdf793ef005b1..e974a3bee8b03bb1e139983447f362f05987d871 100644 (file)
@@ -121,10 +121,6 @@ class ApplicationSelector extends BaseFrameworkSystem {
         * @param               $initScript     The FQFN of init.php
         * @param               $appName                The application's Uni* name
         * @return      void
-        * @throws      AppVarIsNotSetException If 'app' is not set
-        * @throws      NullPointerException    If 'app' is null
-        * @throws      NoObjectException               If 'app' is not an object
-        * @throws      MissingMethodException  If a required method is missing
         */
        private function loadInitScript ($initScript, $appName) {
                // Is it a file and readable?
@@ -132,21 +128,6 @@ class ApplicationSelector extends BaseFrameworkSystem {
                        // Then include it
                        include ($initScript);
 
-                       // We now should have $app re-defined!
-                       if (!isset($app)) {
-                               // This application shall not be loaded
-                               return;
-                       } elseif (is_null($app)) {
-                               // The class instance is null
-                               throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-                       } elseif (!is_object($app)) {
-                               // Not an object
-                               throw new NoObjectException($app, self::EXCEPTION_IS_NO_OBJECT);
-                       } elseif (!method_exists($app, $this->getConfigInstance()->readConfig('entry_method'))) {
-                               // Method not found!
-                               throw new MissingMethodException(array($app, $this->getConfigInstance()->readConfig('entry_method')), self::EXCEPTION_MISSING_METHOD);
-                       }
-
                        // Add the current instance to the list
                        $this->foundApps->append($app);
 
diff --git a/application/ship-simu/exceptions/class_MissingSimulatorIDException.php b/application/ship-simu/exceptions/class_MissingSimulatorIDException.php
deleted file mode 100644 (file)
index 228b95c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * An exception thrown when the provided simulator id is invalid
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @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
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class MissingSimulatorIDException extends FrameworkException {
-       public function __construct (array $classArray, $code) {
-               // Add a message around the missing class
-               $message = sprintf("[%s:] Die Simulator-ID <span id=\"exception_reason\">%s</span> scheint ung&uuml;ltig zu sein.",
-                       $classArray[0]->__toString(),
-                       $classArray[1]
-               );
-
-               // Call parent constructor
-               parent::__construct($message, $code);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/ship-simu/exceptions/class_MissingSimulatorIdException.php b/application/ship-simu/exceptions/class_MissingSimulatorIdException.php
new file mode 100644 (file)
index 0000000..ea3fb23
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * An exception thrown when the provided simulator id is invalid
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class MissingSimulatorIdException extends FrameworkException {
+       public function __construct (array $classArray, $code) {
+               // Add a message around the missing class
+               $message = sprintf("[%s:] Die Simulator-ID <span id=\"exception_reason\">%s</span> scheint ung&uuml;ltig zu sein.",
+                       $classArray[0]->__toString(),
+                       $classArray[1]
+               );
+
+               // Call parent constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index c52ec8de27e8d93cf9a68867a814ce735b25e2d5..28146141255196de8e37ab8046f3457d971d5fba 100644 (file)
@@ -25,7 +25,7 @@ interface Customer extends FrameworkInterface {
        /**
         * Adds a contract to the customer's list
         *
-        * @param               $contractInstance       A valid instance to WorksContract
+        * @param       $contractInstance       A valid instance to WorksContract
         * @return      void
         */
        function addNewWorksContract (SignableContract $contractInstance);
@@ -33,17 +33,10 @@ interface Customer extends FrameworkInterface {
        /**
         * Signs a works contract.
         *
-        * @param               $contractInstance                               A valid instance to WorksContract
-        * @param               $partnerInstance                                An instance the other
-        *                                                                              contract partner
+        * @param       $contractInstance       A valid instance to WorksContract
+        * @param       $partnerInstance        An instance the other contract partner
         * @return      void
-        * @throws      NullPointerException                    If an instance variable
-        *                                                                              is null
-        * @throws      NoObjectException                               If an instance variable
-        *                                                                              is not an object
-        * @throws      MissingMethodException                  If a required method was
-        *                                                                              not found in $contractInstance
-        * @throws      InvalidContractPartnerException If the in $contractInstance
+        * @throws      InvalidContractPartnerException         If the in $contractInstance
         *                                                                              set contract partner is
         *                                                                              not the expected
         */
@@ -52,7 +45,7 @@ interface Customer extends FrameworkInterface {
        /**
         * Withdraw from a signed contract
         *
-        * @param               $contractInstance       A valid instance to WorksContract
+        * @param       $contractInstance       A valid instance to WorksContract
         * @return      void
         */
        function withdrawFromContract (SignableContract $contractInstance);
index b776759bf41d3af5dac2cbfcafc163a3bd7e8778..b25c8ee4aa6e16abf4f301e16262b238c45003e2 100644 (file)
@@ -314,7 +314,7 @@ class WorksContract extends BaseFrameworkSystem implements SignableContract {
                        } elseif (!is_object($item)) {
                                // Not an object! ;-(
                                throw new NoObjectException($item, self::EXCEPTION_IS_NO_OBJECT);
-                       } elseif (!method_exists($item, 'getPartInstance')) {
+                       } elseif (!$item instanceof BaseSimulator) {
                                // Does not have the required feature (method)
                                throw new MissingMethodException(array($item, 'getPartInstance'), self::EXCEPTION_MISSING_METHOD);
                        }
index 9cc0adbf00883678f3a06a6c04bc9ceadb6e3d34..08d69386eda6641c0d67d4a748c146b26ba49bed 100644 (file)
@@ -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
index 196616153b9fb0ceb1537b8b24896c8709fffe83..5b73d5102eb2015c04c5d67ba96221c795489e61 100644 (file)
@@ -26,16 +26,12 @@ interface FrameworkDatabaseInterface extends FrameworkInterface {
         * Analyses if a unique ID has already been used or not. This method does
         * only pass the given ID through to the "real" database layer.
         *
-        * @param               $uniqueID               A unique ID number which shall be checked
-        *                                              before it will be used
-        * @param               $inConstructor  If called from a constructor or from
-        *                                              somewhere else
-        * @return      $isUnused               true    = The unique ID was not found in the database,
-        *                                              false = It is already in use by an other object
-        * @throws      NullPointerException    If $dbInstance is null
-        * @throws      NoObjectException               If $dbInstance is not an object
-        * @throws      MissingMethodException  If the required method
-        *                                                              isUniqueIdUsed() was not found
+        * @param       $uniqueID               A unique ID number which shall be checked
+        *                                                      before it will be used
+        * @param       $inConstructor  If called from a constructor or from
+        *                                                      somewhere else
+        * @return      $isUnused               true = The unique ID was not found in the database,
+        *                                                      false = It is already in use by an other object
         */
        function isUniqueIdUsed ($uniqueID, $inConstructor = false);
 }
index 5dc756b6931ecfa02af6af57eefe1ab25f660bf4..19e81ef1e98f458accd661a2e2b2d23a39e3cc20 100644 (file)
@@ -25,12 +25,8 @@ interface FileInputStreamer extends Streamable {
        /**
         * Reads from a local or remote file
         *
-        * @param               $fqfn   The file's FQFN we shall load
+        * @param       $fqfn   The file's FQFN we shall load
         * @return      $array  An array containing all read lines
-        * @throws      NullPointerException    If an instance is null
-        * @throws      NoObjectException               If the instance is not an object
-        *                                                              instance
-        * @throws      MissingMethodException  If a required method is missing.
         * @throws      InvalidArrayCountException      If an array has not the
         *                                                                      expected size
         * @throws      InvalidMD5ChecksumException     If two MD5 hashes did not match
index 2862c544f7887b74013a6d5b6e9125a36f657394..1c8cd029bdfd4b57d95fd909367f34e528ed54c1 100644 (file)
@@ -26,14 +26,10 @@ interface FileOutputStreamer extends Streamable {
         * Saves streamed (that are mostly serialized objects) data to files or
         * external servers.
         *
-        * @param               $fileName               The local file's name including full path
-        * @param               $dataArray      Array containing the compressor's extension
+        * @param       $fileName       The local file's name including full path
+        * @param       $dataArray      Array containing the compressor's extension
         *                                              and streamed data
         * @return      void
-        * @throws      NullPointerException    If an instance is null
-        * @throws      NoObjectException               If the instance is not an object
-        *                                                              instance
-        * @throws      MissingMethodException  If a required method is missing.
         */
        function saveFile ($fileName, $dataArray);
 }
index c0b8899b1a9d4f4f9aab0142380d2cdca3d178bf..aa5b2aba19c47a6b0ff84db8a22ce500c495bfe3 100644 (file)
@@ -531,27 +531,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
         *
         * @param       $fqfn   The full-qualified file name for a template
         * @return      void
-        * @throws      NullPointerException    If $inputInstance is null
-        * @throws      NoObjectException               If $inputInstance is not an object
-        * @throws      MissingMethodException  If $inputInstance is missing a
-        *                                                                      required method
         */
        private function loadRawTemplateData ($fqfn) {
                // Get a input/output instance from the middleware
                $ioInstance = $this->getFileIoInstance();
 
-               // Validate the instance
-               if (is_null($ioInstance)) {
-                       // Throw exception
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($ioInstance)) {
-                       // Throw another exception
-                       throw new NoObjectException($ioInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($ioInstance, 'loadFileContents')) {
-                       // Throw yet another exception
-                       throw new MissingMethodException(array($ioInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Some debug code to look on the file which is being loaded
                //* DEBUG: */ echo __METHOD__.": FQFN=".$fqfn."<br />\n";
 
index ed1f8d03d636f4500e957c4d42a3a8328ac22c22..c67da37468ef84faee79f28ca74d86c6fffdb65a 100644 (file)
@@ -110,18 +110,6 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
         * @return      void
         */
        public final function output ($outStream) {
-               // Check if the output instance is valid
-               if (is_null($this->outputInstance)) {
-                       // Debug output instance was not set
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($this->outputInstance)) {
-                       // The debug output instance is not an object
-                       throw new NoObjectException($this->ouputInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!$this->outputInstance instanceof Debugger) {
-                       // The required method outputStream() is missing
-                       throw new MissingMethodException(array($this->outputInstance, 'outputStream'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Is the output stream set
                if (empty($outStream)) {
                        // Initialization phase
index 99cb434e16a1379a2a2220834fbcf062f7bb8b56..e5648106bb7cbe29b471ccdb51f2033e83604e42 100644 (file)
@@ -61,7 +61,7 @@ class FileIoHandler extends BaseMiddleware {
         * Creates an instance of this class and prepares the IO system. This is
         * being done by setting the default file IO class
         *
-        * @return      $ioInstance     A prepared instance of FilIOHandler
+        * @return      $ioInstance             A prepared instance of FilIOHandler
         */
        public final static function createFileIoHandler () {
                // Get instance
@@ -87,7 +87,8 @@ class FileIoHandler extends BaseMiddleware {
        /**
         * Setter for the *real* file input instance
         *
-        * @param               $inputStream    The *real* file-input class
+        * @param       $inputStream    The *real* file-input class
+        * @return      void
         */
        public final function setInputStream (FileInputStreamer $inputStream) {
                $this->inputStream = $inputStream;
@@ -105,7 +106,8 @@ class FileIoHandler extends BaseMiddleware {
        /**
         * Setter for the *real* file output instance
         *
-        * @param               $outputStream   The *real* file-output class
+        * @param       $outputStream   The *real* file-output class
+        * @return      void
         */
        public final function setOutputStream (FileOutputStreamer $outputStream) {
                $this->outputStream = $outputStream;
@@ -123,51 +125,28 @@ class FileIoHandler extends BaseMiddleware {
        /**
         * Saves a file with data by using the current output stream
         *
-        * @see FileOutputStreamer
+        * @param       $fileName       Name of the file
+        * @param       $dataArray      Array with file contents
+        * @return      void
+        * @see         FileOutputStreamer
         */
        public function saveFile ($fileName, $dataArray) {
                // Get output stream
                $outInstance = $this->getOutputStream();
 
-               // Is it a valid stream?
-               if (is_null($outInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($outInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($outInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($outInstance, 'saveFile')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($outInstance, 'saveFile'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Send the fileName and dataArray to the output handler
                $outInstance->saveFile($fileName, $dataArray);
        }
 
        /** Loads data from a file over the input handler
         *
-        * @see FileInputStreamer
+        * @return      $array  Array with the file contents
+        * @see         FileInputStreamer
         */
        public function loadFileContents ($fqfn) {
-               // Initialize the array
-               $array = array();
-
                // Get output stream
                $inInstance = $this->getInputStream();
 
-               // Is it a valid stream?
-               if (is_null($inInstance)) {
-                       // No class returned
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_object($inInstance)) {
-                       // Not an object! ;-(
-                       throw new NoObjectException($inInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($inInstance, 'loadFileContents')) {
-                       // Nope, so throw exception
-                       throw new MissingMethodException(array($inInstance, 'loadFileContents'), self::EXCEPTION_MISSING_METHOD);
-               }
-
                // Read from the input handler
                return $inInstance->loadFileContents($fqfn);
        }