Skip to content

Commit

Permalink
Add soundex
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpanderson committed Jun 21, 2024
1 parent b9a2004 commit e484b3c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"source": "https://github.com/Vectorface/MySQLite"
},
"require": {
"php": "^8.0.0"
"php": "^8.0.0",
"ext-pdo": "*"
},
"require-dev": {
"phpunit/phpunit": "^9",
Expand Down
8 changes: 8 additions & 0 deletions src/Vectorface/MySQLite/MySQL/StringFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ public static function mysql_format()
$decimals = isset($args[1]) ? $args[1] : 0;
return number_format($number, $decimals);
}

/**
* Get the soundex value of a given string
*/
public static function mysql_soundex(string $str): string
{
return soundex($str);
}
}
5 changes: 5 additions & 0 deletions tests/Vectorface/Tests/MySQLite/MySQLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,9 @@ public function testFormat()
$test = MySQLite::mysql_format("12.232", 1);
$this->assertEquals($expected, $test);
}

public function testSoundex()
{
$this->assertEquals("F000", MySQLite::mysql_soundex("foo"));
}
}

0 comments on commit e484b3c

Please sign in to comment.