@@ -65,7 +65,7 @@ public function isValid() {
65
65
* @return int Checksum
66
66
*/
67
67
public static function calculateChecksum ($ number , $ length = 0 ) {
68
- $ number = strval (self ::stringToInteger ($ number ));
68
+ $ number = strval (self ::toInteger ($ number ));
69
69
70
70
if ($ length === 0 ) {
71
71
$ length = strlen ($ number );
@@ -80,7 +80,7 @@ public static function calculateChecksum($number, $length = 0) {
80
80
81
81
// If a 2 digit number, split and add togheter
82
82
if ($ tmp > 9 ) {
83
- $ tmp = intval ($ tmp / 10 ) + intval ($ tmp % 10 );
83
+ $ tmp = ($ tmp / 10 ) + ($ tmp % 10 );
84
84
}
85
85
86
86
// Sum it upp
@@ -147,12 +147,13 @@ public function getCheckDigit() {
147
147
}
148
148
149
149
/**
150
- * Fix a string so that it only contains numbers
151
- * @param string $integer String to convert to integer
152
- * @return int An integer
150
+ * Remove all but numbers from a string
151
+ *
152
+ * @param string $string String to "convert" to integer
153
+ * @return string String containing only numbers
153
154
*/
154
- public static function stringToInteger ( $ integer ) {
155
- return intval ( preg_replace ("/[^0-9 ]/ " , "" , $ integer ) );
155
+ public static function toInteger ( $ string ) {
156
+ return preg_replace ("/[^\d ]/ " , "" , $ string );
156
157
}
157
158
158
159
/**
@@ -162,7 +163,7 @@ public static function stringToInteger($integer) {
162
163
* included in $number?
163
164
*/
164
165
public function setNumber ($ number , $ withCheckDigit = true ) {
165
- $ number = strval (self ::stringToInteger ($ number ));
166
+ $ number = strval (self ::toInteger ($ number ));
166
167
$ length = strlen ($ number );
167
168
168
169
// If number does not include checkdigit, calculate it!
0 commit comments