Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
tumugin committed Apr 7, 2022
1 parent f491901 commit c06b022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
30 changes: 10 additions & 20 deletions src/SnNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ public function toFloat(): float
*/
public function isEqual($value): bool
{
if (is_int($value) || is_float($value)) {
return $this->value === $value;
}
return $this->value === $value->value;
$rawValue = is_int($value) || is_float($value) ? $value : $value->value;
return $this->value === $rawValue;
}

/**
Expand All @@ -76,10 +74,8 @@ public function isEqual($value): bool
*/
public function isGreaterOrEqualThan($value): bool
{
if (is_int($value) || is_float($value)) {
return $this->value === $value;
}
return $this->value >= $value->value;
$rawValue = is_int($value) || is_float($value) ? $value : $value->value;
return $this->value >= $rawValue;
}

/**
Expand All @@ -89,10 +85,8 @@ public function isGreaterOrEqualThan($value): bool
*/
public function isGreaterThan($value): bool
{
if (is_int($value) || is_float($value)) {
return $this->value === $value;
}
return $this->value > $value->value;
$rawValue = is_int($value) || is_float($value) ? $value : $value->value;
return $this->value > $rawValue;
}

/**
Expand All @@ -102,10 +96,8 @@ public function isGreaterThan($value): bool
*/
public function isLessOrEqualThan($value): bool
{
if (is_int($value) || is_float($value)) {
return $this->value === $value;
}
return $this->value <= $value->value;
$rawValue = is_int($value) || is_float($value) ? $value : $value->value;
return $this->value <= $rawValue;
}

/**
Expand All @@ -115,10 +107,8 @@ public function isLessOrEqualThan($value): bool
*/
public function isLessThan($value): bool
{
if (is_int($value) || is_float($value)) {
return $this->value === $value;
}
return $this->value < $value->value;
$rawValue = is_int($value) || is_float($value) ? $value : $value->value;
return $this->value < $rawValue;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/SnString.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ public function length(): SnInteger
*/
public function equals($value): bool
{
if (is_string($value)) {
return $this->value === $value;
}
return $this->value === $value->value;
$rawValue = is_string($value) ? $value : $value->value;
return $this->value === $rawValue;
}

/**
Expand All @@ -108,10 +106,8 @@ public function equals($value): bool
*/
public function concat($value)
{
if (is_string($value)) {
return new static($this->value . $value);
}
return new static($this->value . $value->value);
$rawValue = is_string($value) ? $value : $value->value;
return new static($this->value . $rawValue);
}

/**
Expand Down

0 comments on commit c06b022

Please sign in to comment.