A service to expand abbreviations:
namespace Jstewmc\ExpandAbbreviations;
// define replacements (i.e., replace "foo" with "bar")
$replacements = ['foo' => 'bar'];
// instantiate service
$service = new ExpandAbbreviations($replacements);
// expand abbreviations
$service('foo bar baz'); // returns "bar bar baz"
$service('foo. bar baz'); // returns "bar bar baz"
$service('qux'); // returns "qux"
Given an array of replacements indexed by abbreviation, this library will expand all occurences of an abbreviation in a string to its corresponding replacement.
Keep in mind, this library is case-sensitive but trailing-period agnostic.
- Initial release