Cleaned up bool comparison mess

This commit is contained in:
Dylan K. Taylor
2018-03-19 14:10:55 +00:00
parent 24c5d7557e
commit ac5a91b67e
39 changed files with 141 additions and 141 deletions

View File

@@ -140,7 +140,7 @@ class Config{
$this->config = $default;
$this->save();
}else{
if($this->correct === true){
if($this->correct){
$content = file_get_contents($this->file);
switch($this->type){
case Config::PROPERTIES:
@@ -183,7 +183,7 @@ class Config{
* @return bool
*/
public function check() : bool{
return $this->correct === true;
return $this->correct;
}
/**
@@ -192,7 +192,7 @@ class Config{
* @return bool
*/
public function save(bool $async = false) : bool{
if($this->correct === true){
if($this->correct){
try{
$content = null;
switch($this->type){
@@ -456,7 +456,7 @@ class Config{
* @return bool
*/
public function exists($k, bool $lowercase = false) : bool{
if($lowercase === true){
if($lowercase){
$k = strtolower($k); //Convert requested key to lower
$array = array_change_key_case($this->config, CASE_LOWER); //Change all keys in array to lower
return isset($array[$k]); //Find $k in modified array
@@ -479,7 +479,7 @@ class Config{
* @return array
*/
public function getAll(bool $keys = false) : array{
return ($keys === true ? array_keys($this->config) : $this->config);
return ($keys ? array_keys($this->config) : $this->config);
}
/**
@@ -535,8 +535,8 @@ class Config{
private function writeProperties() : string{
$content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
foreach($this->config as $k => $v){
if(is_bool($v) === true){
$v = $v === true ? "on" : "off";
if(is_bool($v)){
$v = $v ? "on" : "off";
}elseif(is_array($v)){
$v = implode(";", $v);
}

View File

@@ -108,7 +108,7 @@ class MainLogger extends \AttachableThreadedLogger{
}
public function debug($message, bool $force = false){
if($this->logDebug === false and !$force){
if(!$this->logDebug and !$force){
return;
}
$this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY);
@@ -263,7 +263,7 @@ class MainLogger extends \AttachableThreadedLogger{
throw new \RuntimeException("Couldn't open log file");
}
while($this->shutdown === false){
while(!$this->shutdown){
$this->writeLogStream($logResource);
$this->synchronized(function(){
$this->wait(25000);

View File

@@ -123,50 +123,50 @@ abstract class TextFormat{
if($color !== "white"){
$pointer["color"] = $color;
}
if($bold !== false){
if($bold){
$pointer["bold"] = true;
}
if($italic !== false){
if($italic){
$pointer["italic"] = true;
}
if($underlined !== false){
if($underlined){
$pointer["underlined"] = true;
}
if($strikethrough !== false){
if($strikethrough){
$pointer["strikethrough"] = true;
}
if($obfuscated !== false){
if($obfuscated){
$pointer["obfuscated"] = true;
}
++$index;
}
switch($token){
case TextFormat::BOLD:
if($bold === false){
if(!$bold){
$pointer["bold"] = true;
$bold = true;
}
break;
case TextFormat::OBFUSCATED:
if($obfuscated === false){
if(!$obfuscated){
$pointer["obfuscated"] = true;
$obfuscated = true;
}
break;
case TextFormat::ITALIC:
if($italic === false){
if(!$italic){
$pointer["italic"] = true;
$italic = true;
}
break;
case TextFormat::UNDERLINE:
if($underlined === false){
if(!$underlined){
$pointer["underlined"] = true;
$underlined = true;
}
break;
case TextFormat::STRIKETHROUGH:
if($strikethrough === false){
if(!$strikethrough){
$pointer["strikethrough"] = true;
$strikethrough = true;
}
@@ -176,23 +176,23 @@ abstract class TextFormat{
$pointer["color"] = "white";
$color = "white";
}
if($bold !== false){
if($bold){
$pointer["bold"] = false;
$bold = false;
}
if($italic !== false){
if($italic){
$pointer["italic"] = false;
$italic = false;
}
if($underlined !== false){
if($underlined){
$pointer["underlined"] = false;
$underlined = false;
}
if($strikethrough !== false){
if($strikethrough){
$pointer["strikethrough"] = false;
$strikethrough = false;
}
if($obfuscated !== false){
if($obfuscated){
$pointer["obfuscated"] = false;
$obfuscated = false;
}

View File

@@ -130,9 +130,9 @@ class Utils{
* @return string|bool
*/
public static function getIP(bool $force = false){
if(Utils::$online === false){
if(!Utils::$online){
return false;
}elseif(Utils::$ip !== false and $force !== true){
}elseif(Utils::$ip !== false and !$force){
return Utils::$ip;
}
@@ -438,7 +438,7 @@ class Utils{
* @throws \RuntimeException if a cURL error occurs
*/
public static function simpleCurl(string $page, $timeout = 10, array $extraHeaders = [], array $extraOpts = [], callable $onSuccess = null){
if(Utils::$online === false){
if(!Utils::$online){
throw new \RuntimeException("Server is offline");
}

View File

@@ -92,7 +92,7 @@ class VersionString{
}
public function get(bool $build = false) : string{
return $this->getRelease() . ($this->development === true ? "dev" : "") . (($this->build > 0 and $build === true) ? "-" . $this->build : "");
return $this->getRelease() . ($this->development ? "dev" : "") . (($this->build > 0 and $build) ? "-" . $this->build : "");
}
public function __toString() : string{
@@ -106,12 +106,12 @@ class VersionString{
* @return int
*/
public function compare($target, bool $diff = false) : int{
if(($target instanceof VersionString) === false){
if(!($target instanceof VersionString)){
$target = new VersionString($target);
}
$number = $this->getNumber();
$tNumber = $target->getNumber();
if($diff === true){
if($diff){
return $tNumber - $number;
}
if($number > $tNumber){