X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fcompanies%2Fclass_ShippingCompany.php;h=de959b62f836e6f272d9de6d6e74e676a24994bf;hp=7a00527ffa33504c8600a871aca9d3e59df05ea1;hb=4f70843ae8428f051d70ccff5bb43fc4c03dda8d;hpb=ec23e72b16433ac136817f3ea78697fb70236e4a diff --git a/application/ship-simu/main/companies/class_ShippingCompany.php b/application/ship-simu/main/companies/class_ShippingCompany.php index 7a00527..de959b6 100644 --- a/application/ship-simu/main/companies/class_ShippingCompany.php +++ b/application/ship-simu/main/companies/class_ShippingCompany.php @@ -2,11 +2,11 @@ /** * A shipping company may be founded with this class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.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 @@ -81,8 +81,9 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner * * @param $userInstance A user class * @return $companyInstance Prepared company instance + * @todo Add functionality if user participates in a company */ - public final static function createShippingCompany (ManageableAccount $userInstance) { + public static final function createShippingCompany (ManageableAccount $userInstance) { // Get new instance $companyInstance = new ShippingCompany(); @@ -133,6 +134,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner * Checks wether the current user in registry is the company founder * * @return $isFounder Wether the current user is the company founder + * @todo Check if user is company founder */ public function ifUserIsFounder () { // Default is not the founder @@ -155,6 +157,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner * Checks wether the current user in registry is the company owner * * @return $isOwner Wether the current user is the company owner + * @todo Check if user is company owner */ public function ifUserIsOwner () { // Default is not the owner @@ -322,7 +325,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner $iterator->seek($pos); // Is the current position valid? - if (!$iterator->valid()) { + if ($iterator->valid() === false) { // Should normally not happen... :( throw new StructuresOutOfBoundsException($idx, self::EXCEPTION_INDEX_OUT_OF_BOUNDS); } // END - if @@ -386,10 +389,10 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Iterate through all employees for ($idx = $this->employeeList->getIterator(); $idx->valid(); $idx->next()) { // Is the shipyard iterator still okay? - if (!$shipyardIter->valid()) { + if ($shipyardIter->valid() === false) { // Rewind to first position $shipyardIter->seek(0); - } + } // END - if // Get Shipyard object $shipyard = $shipyardIter->current(); @@ -400,8 +403,8 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Nope, so throw exception throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } @@ -468,7 +471,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Is the class there? if (!class_exists($shipType)) { // Throw exception - throw new ClassNotFoundException($shipType, self::EXCEPTION_CLASS_NOT_FOUND); + throw new NoClassException($shipType, self::EXCEPTION_CLASS_NOT_FOUND); } // Create dummy ship @@ -488,15 +491,15 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Class is not a shipyard throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } // Add the new ship type to the shipyard $shipyard->addNewConstructableShipType($shipType); - } + } // END - for } // Validate the requested ship type with the company if they can construct it @@ -510,13 +513,13 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipInstance)) { // Not an object! ;-( - throw new NoObjectException($shipInstance, self::EXCEPTION_IS_NO_OBJECT); + throw new InvalidObjectException($shipInstance, self::EXCEPTION_IS_NO_OBJECT); } // Get it's real class name $shipType = $shipInstance->__toString(); - // Now check if the ship type is in any list and return the result + // Now check if ship type is in any list and return the result return ($this->isShipTypeConstructable($shipType)); } @@ -547,18 +550,18 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($shipyard)) { // Not an object! ;-( - throw new NoObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$shipyard->isClass("Shipyard")) { + throw new InvalidObjectException($shipyard, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($shipyard->isClass("Shipyard") === false) { // Class is not a shipyard throw new ClassMismatchException(array($shipyard->__toString(), "Shipyard"), self::EXCEPTION_CLASSES_NOT_MATCHING); } - // Validate if the first found shipyard can construct the requested type + // Validate if first found shipyard can construct the requested type $result = $shipyard->isShipTypeConstructable($shipType); // Does this shipyard construct the requested ship type? if ($result) break; // Then abort the search! - } + } // END - for // Debug message if ((defined('DEBUG_COMPANY')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Die Reederei %s hat die Suche nach einer Werft beendet, die Schiffe vom Typ %s bauen kann.", @@ -597,10 +600,10 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // Sign a contract with an other party which must also implement Customer public function signContract (SignableContract $contractInstance, ContractPartner $partnerInstance) { // Check wether the other party is our contract partner - if (!$partnerInstance->isContractPartner($contractInstance)) { + if ($partnerInstance->isContractPartner($contractInstance) === false) { // Invalid contract partner! throw new InvalidContractPartnerException($partnerInstance, self::EXCEPTION_CONTRACT_PARTNER_INVALID); - } + } // END - if // Determine if company "signs" own contract (must be done) or with an other party if ($this->equals($partnerInstance)) { @@ -648,8 +651,8 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (!is_object($contractInstance)) { // Not an object! ;-( - throw new NoObjectException($contractInstance, self::EXCEPTION_IS_NO_OBJECT); - } elseif (!$contractInstance->isClass('WorksContract')) { + throw new InvalidObjectException($contractInstance, self::EXCEPTION_IS_NO_OBJECT); + } elseif ($contractInstance->isClass("WorksContract") === false) { // Is not a merchant throw new ClassMismatchException(array($contractInstance->__toString(), "WorksContract"), self::EXCEPTION_CLASSES_NOT_MATCHING); }