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
* @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?
// 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);
+++ /dev/null
-<?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ültig zu sein.",
- $classArray[0]->__toString(),
- $classArray[1]
- );
-
- // Call parent constructor
- parent::__construct($message, $code);
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+<?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ültig zu sein.",
+ $classArray[0]->__toString(),
+ $classArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
/**
* 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);
/**
* 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
*/
/**
* 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);
} 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);
}
* 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
// 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
* 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);
}
/**
* 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
* 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);
}
*
* @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";
* @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
* 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
/**
* 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;
/**
* 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;
/**
* 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);
}