-<?php
-// Own namespace
-namespace Org\Mxchange\City\Manager\Region;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
-
-/**
- * A game manager
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2015, 2016 City Developer Team
- * @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 RegionManager extends BaseManager implements ManageableRegion {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $managerInstance An instance of a ManageableRegion class
- */
- public final static function createRegionManager () {
- // Get new instance
- $managerInstance = new RegionManager();
-
- // Get database wrapper
- $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('region_info_db_wrapper_class');
-
- // And set it here
- $managerInstance->setWrapperInstance($wrapperInstance);
-
- // Return the prepared instance
- return $managerInstance;
- }
-
- /**
- * Checks whether the current user has already founded a region
- *
- * @return $isFounded Whether the current user has already founded a region
- */
- public function ifUserHasCreatedRegion () {
- // Check if the currently set user has already founded a region
- $isFounded = $this->getWrapperInstance()->ifUserHasCreatedRegion();
-
- // Return result
- return $isFounded;
- }
-
- /**
- * Checks whether the given region name is already taken
- *
- * @para $regionName Name of region
- * @return $isTaken Whether the given region name is already taken
- */
- public function ifRegionNameExists ($regionName) {
- // Check if the given region name is taken
- $isTaken = $this->getWrapperInstance()->ifRegionExists($regionName);
-
- // Return result
- return $isTaken;
- }
-
- /**
- * Founds the first region. A dummy region will also be created
- *
- * @return $resultInstance Found result after creating it
- */
- public function createFirstRegion () {
- // Dummy name
- // @TODO Move to language system
- $regionName = 'Region 1';
-
- // Some pre-checks
- assert(!$this->ifUserHasCreatedRegion());
- assert(!$this->ifRegionNameExists($regionName));
-
- // First region can now be created
- $this->getWrapperInstance()->createRegionByName($regionName);
-
- // Then try to find it
- assert($this->ifRegionNameExists($regionName));
-
- // Get result instance
- $resultInstance = $this->getResultInstance();
-
- // And return it
- return $resultInstance;
- }
-}