https://github.com/bpolaszek/violin
Manipulate your strings with no wrong note.
https://github.com/bpolaszek/violin
Last synced: 11 months ago
JSON representation
Manipulate your strings with no wrong note.
- Host: GitHub
- URL: https://github.com/bpolaszek/violin
- Owner: bpolaszek
- License: mit
- Created: 2018-06-27T15:28:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-07T14:37:22.000Z (over 6 years ago)
- Last Synced: 2025-02-10T11:17:32.246Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://packagist.org/packages/bentools/violin)
[](https://packagist.org/packages/bentools/violin)
[](https://travis-ci.org/bpolaszek/violin)
[](https://coveralls.io/github/bpolaszek/violin?branch=master)
[](https://scrutinizer-ci.com/g/bpolaszek/violin)
[](https://packagist.org/packages/bentools/violin)
# Violin 🎻
Violin is a multibyte-compliant, OOP string manipulation library.
It is heavily inspired by [Stringy](https://github.com/danielstjules/Stringy), with a main focus on performance: when dealing with thousands of strings, it is sometimes counter-productive to rely on `mb_*` functions, which perform up to 4 times slower than normal `str_*` functions, when you manipulate ASCII strings.
Violin will detect the string's encoding, then decide wether or not to use the mbstring extension (or the Symfony polyfill if the extension is not loaded).
## Installation
PHP 7.1+ is required.
```bash
composer require bentools/violin 1.0.x-dev
```
## Tests
```bash
./vendor/bin/phpunit
```
## Usage
```php
use BenTools\Violin\Violin;
$str = 'fòöbà ř 🤗';
print Violin::tune($str)
->toUpperCase()
->ensureLeft('Welcome ')
->collapseWhitespace(); // Welcome FÒÖBÀŘ 🤗
```
## License
MIT