Code Duplication    Length = 15-18 lines in 2 locations

control/Director.php 2 locations

@@ 1016-1030 (lines=15) @@
1013
	 * This function will return true if the site is in a development environment.
1014
	 * For information about environment types, see {@link Director::set_environment_type()}.
1015
	 */
1016
	public static function isDev() {
1017
		// Check session
1018
		if($env = self::session_environment()) return $env === 'dev';
1019
1020
		// Check config
1021
		if(Config::inst()->get('Director', 'environment_type') === 'dev') return true;
1022
1023
		// Check if we are running on one of the test servers
1024
		$devServers = (array)Config::inst()->get('Director', 'dev_servers');
1025
		if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], $devServers))  {
1026
			return true;
1027
		}
1028
1029
		return false;
1030
	}
1031
1032
	/**
1033
	 * This function will return true if the site is in a test environment.
@@ 1036-1053 (lines=18) @@
1033
	 * This function will return true if the site is in a test environment.
1034
	 * For information about environment types, see {@link Director::set_environment_type()}.
1035
	 */
1036
	public static function isTest() {
1037
		// In case of isDev and isTest both being set, dev has higher priority
1038
		if(self::isDev()) return false;
1039
1040
		// Check saved session
1041
		if($env = self::session_environment()) return $env === 'test';
1042
1043
		// Check config
1044
		if(Config::inst()->get('Director', 'environment_type') === 'test') return true;
1045
1046
		// Check if we are running on one of the test servers
1047
		$testServers = (array)Config::inst()->get('Director', 'test_servers');
1048
		if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], $testServers))  {
1049
			return true;
1050
		}
1051
1052
		return false;
1053
	}
1054
1055
	/**
1056
	 * Check or update any temporary environment specified in the session