Skip to content

Commit 2bf72c7

Browse files
author
Wazabii
committed
Added compare method
1 parent 0bb381d commit 2bf72c7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Format/Str.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,19 @@ public function toBool(): bool
420420
}
421421
return ($this->value !== "false" && strlen($this->value));
422422
}
423+
424+
/**
425+
* Compare value to value
426+
* @param string|int|float|bool|null $compare
427+
* @return bool
428+
*/
429+
public function compare(string|int|float|bool|null $compare): bool
430+
{
431+
if(is_numeric($this->value)) {
432+
return ((float)$this->value > 0);
433+
}
434+
return ($this->value === $compare);
435+
}
423436

424437
/**
425438
* To int value

0 commit comments

Comments
 (0)