Skip to content

Commit 67be35e

Browse files
committed
Improve SizeTrait for integers
1 parent fff6ee2 commit 67be35e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Rules/Traits/SizeTrait.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ trait SizeTrait
1515
*/
1616
protected function getValueSize($value)
1717
{
18-
if (is_int($value) || is_numeric($value)) {
18+
if ( $this->getAttribute() && ( $this->getAttribute()->hasRule( 'numeric' ) || $this->getAttribute()->hasRule( 'integer' ) ) && is_numeric( $value ) ) {
19+
$value = (float) $value;
20+
}
21+
22+
if ( is_int( $value ) || is_float( $value ) ) {
1923
return (float) $value;
20-
} elseif (is_string($value)) {
21-
return (float) mb_strlen($value, 'UTF-8');
22-
} elseif ($this->isUploadedFileValue($value)) {
24+
} elseif ( is_string( $value ) ) {
25+
return (float) mb_strlen( $value, 'UTF-8' );
26+
} elseif ( $this->isUploadedFileValue( $value ) ) {
2327
return (float) $value['size'];
24-
} elseif (is_array($value)) {
25-
return (float) count($value);
28+
} elseif ( is_array( $value ) ) {
29+
return (float) count( $value );
2630
} else {
2731
return false;
2832
}

0 commit comments

Comments
 (0)