namespace CoreFramework\Configuration;
// Import framework stuff
+use CoreFramework\Console\Tools\ConsoleTools;
+use CoreFramework\Dns\UnknownHostnameException;
use CoreFramework\Generic\FrameworkInterface;
use CoreFramework\Generic\NullPointerException;
+use CoreFramework\Generic\UnsupportedOperationException;
use CoreFramework\Registry\Registerable;
/**
ksort($this->config);
}
+ /**
+ * Getter for whole configuration array
+ *
+ * @return $config Configuration array
+ */
+ public final function getConfigurationArray () {
+ // Return it
+ return $this->config;
+ }
+
/**
* Unset a configuration key, the entry must be there or else an
* exception is thrown.
* Detects the server address (SERVER_ADDR) and set it in configuration
*
* @return $serverAddress The detected server address
- * @todo We have to add some more entries from $_SERVER here
+ * @throws UnknownHostnameException If SERVER_NAME cannot be resolved to an IP address
+ * @todo Have to check some more entries from $_SERVER here
*/
public function detectServerAddress () {
// Is the entry set?
if (isset($_SERVER['SERVER_ADDR'])) {
// Set it from $_SERVER
$this->setServerAddress($_SERVER['SERVER_ADDR']);
- } elseif (class_exists('ConsoleTools')) {
+ } elseif (isset($_SERVER['SERVER_NAME'])) {
+ // Resolve IP address
+ $serverIp = ConsoleTools::resolveIpAddress($_SERVER['SERVER_NAME']);
+
+ // Is it valid?
+ if ($serverIp === false) {
+ /*
+ * Why is gethostbyname() returning the host name and not
+ * false as many other PHP functions are doing? ;-(
+ */
+ throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
+ } // END - if
+
+ // Al fine, set it
+ $this->setServerAddress($serverIp);
+ } else {
// Run auto-detecting through console tools lib
ConsoleTools::acquireSelfIPAddress();
}
/**
* Detects the HTTPS flag
*
- * @return $https The detected HTTPS flag or null if failed
+ * @return $isSecured The detected HTTPS flag or null if failed
*/
public function detectHttpSecured () {
// Default is null
- $https = NULL;
+ $isSecured = NULL;
// Is HTTPS set?
if ($this->isHttpSecured()) {
// Then use it
- $https = $_SERVER['HTTPS'];
+ $isSecured = $_SERVER['HTTPS'];
} // END - if
// Return it
- return $https;
+ return $isSecured;
}
/**
* @throws NullPointerException If the result instance is null
*/
public final function getField ($fieldName) {
- // Our super interface "FrameworkInterface" requires this
+ // The super interface "FrameworkInterface" requires this
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @throws NullPointerException If the result instance is null
*/
public function isFieldSet ($fieldName) {
- // Our super interface "FrameworkInterface" requires this
+ // The super interface "FrameworkInterface" requires this
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
public function equals (FrameworkInterface $objectInstance) {
// Now test it
$equals = ((
- $this->__toString() == $objectInstance->__toString()
+ $this->__toString() === $objectInstance->__toString()
) && (
- $this->hashCode() == $objectInstance->hashCode()
+ $this->hashCode() === $objectInstance->hashCode()
));
// Return the result