function testIsNull() { $null = null; // valid true values $this->assertTrue(ObjectUtils::isNull(null)); $this->assertTrue(ObjectUtils::isNull(NULL)); $this->assertTrue(ObjectUtils::isNull($this->notInitialized)); $this->assertTrue(ObjectUtils::isNull($null)); // valid false values $this->assertFalse(ObjectUtils::isNull(false)); $this->assertFalse(ObjectUtils::isNull(0)); }
/** * Get message associated with key. Allow default value if not found and * allow preservation of whitespace. * * @param string $key Key to message you're looking for. * @param string $default Default value if key was not found. * @param boolean $preserveExtraSpace Flag indicating whether ot preserve * whitespace or trim value. * * @return string Message value or default value. * * @throws Exception if no default and key not found. * * @todo Determine a way for the default to be explicitly null. * @todo Consider stripping first space even if flag for preserving space * is set to true as standard practice in properties files is for there to * be at least one space after the equals. */ public function get($key, $default = NULL, $preserveExtraSpace = FALSE) { // if found, return it if (array_key_exists($key, $this->properties)) { $value = $this->properties[$key]; if ($preserveExtraSpace) { // TODO: consider stripping first space if present for consistency return $value; } return trim($value); // not found, throw exception } else { if (ObjectUtils::isNull($default)) { throw new Exception("No property was found with the key \"" . $key . "\" in the file \"" . $this->file . "\"."); } else { return $default; } } }