Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpclarkson/stringy
Stringy - Object Oriented Manipulation of Strings in PHP!
https://github.com/mpclarkson/stringy
php strings swift
Last synced: 26 days ago
JSON representation
Stringy - Object Oriented Manipulation of Strings in PHP!
- Host: GitHub
- URL: https://github.com/mpclarkson/stringy
- Owner: mpclarkson
- License: other
- Created: 2015-11-09T03:37:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-04-08T01:06:53.000Z (over 5 years ago)
- Last Synced: 2024-04-19T04:02:39.340Z (7 months ago)
- Topics: php, strings, swift
- Language: PHP
- Size: 11.7 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Stringy - Object Oriented Manipulation of Strings in PHP!
=========================================================[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpclarkson/stringy/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpclarkson/stringy/?branch=master)
[![Build Status](https://travis-ci.org/mpclarkson/stringy.svg?branch=master)](https://travis-ci.org/mpclarkson/stringy)Overview
--------Are you stick to death of PHP's inconsistencies in terms on manipulating strings? Well, look no further!
Rather than constantly having to write obtuse code like this to check if a string contains a substring:
``` php
strpos($mystring, $substring) !== false ? true : false;```
You can now do this (and many other things), sensibly!
``` php
$string = new String($myString);$bool = $string->contains($substring);
```
Yay! :)
Usage
------------After applying any methods, the underlying text/string can be accessed as follows:
```php
$stringy = new Stringy("mystring");
$stringy->append("is fun", " ");echo $stringy->string();
//"mystring is fun";```
Methods
------------Method | Parameters | Returns
--- | --- | ---
string | nil | string
truncate | $chars = 50, $appendWith = "..." | $this
length | nil | int
contains | $substring | bool
startsWith | $substring | bool
endsWith | $substring | bool
append | $string | $this
reverse | nil | $this
uppercase | nil | $this
uppercaseFirst | nil | $this
lowercase | nil | $this
lowercaseFirst | nil | $this
titleCase | nil | $this
sentenceCase | nil | $this
toArray | $delimiter = null | array
apply | callback | $thisCheckout the tests for examples of each method.
Requirements
------------* PHP 5.4+
Composer
---------Use [Composer](https://getcomposer.org) by adding the following lines in your `composer.json`:
```json
"require": {
"mpclarkson/stringy": "dev-master"
},```
Todos
-----* More methods
* Contributions welcomeCredits
-----This has been inspired by the beautify string manipulation in Apple's Swift language.
Thanks goes to [Paper Planes Digital Marketing in Brisbane](https://flypaperplanes.co).