Skip to content

Commit e85a718

Browse files
Merge pull request #22 from dutchenkoOleg/master
str2number method
2 parents f70b978 + 752bab3 commit e85a718

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/WezomAgency/R2D2.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ public function resourceContent($path)
119119
}
120120

121121

122+
/**
123+
* @param string $value
124+
* @param bool $int
125+
* @return int|float
126+
*/
127+
public function str2number($value = '', $int = false)
128+
{
129+
if (strpos('%')) {
130+
return 0;
131+
}
132+
return $int ? intval($value) : floatval($value);
133+
}
134+
135+
122136
/**
123137
* @param string $value
124138
* @return string

0 commit comments

Comments
 (0)