Skip to content

Commit

Permalink
Merge from develop (#6)
Browse files Browse the repository at this point in the history
* Added more test coverage.

* Added StyleCI

* Fixed the Style

* Refactored code and unit test.

* Remove globals.

* Minor refactor

* Minor refactor

* Minor refactor

* Updated the PHPdocs

* Changed the comment positioning

* Update .scrutinizer.yml

* Update .scrutinizer.yml

* Removed scruitnizer and StyleCI

* Added documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* Update Collection.md

* Update Collection.md

* Create ArrayHelper.md

* Update Collection.md

* Update index.md

* Added Encrypter documentation.

* Update composer.json

* Documentation for StringHelper

* Documentation for StringHelper

* Updated the Collection.

* Minor composer.json refactor.

* Refactored the test.
  • Loading branch information
nicholasnet authored Nov 22, 2016
1 parent f1ee088 commit 2570192
Show file tree
Hide file tree
Showing 9 changed files with 528 additions and 381 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
"branch-alias": {
"dev-master": "1.x-dev"
}
}
},
"suggest": {
"ext-intl": "To use StringHelper::ascii() or StringHelper::slug()"
},
"minimum-stability": "dev"
}
81 changes: 76 additions & 5 deletions docs/Utils/StringHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,40 @@ Back to [index](../index.md)

<a name="introduction"></a>
## Introduction
#### This class is inspired by Laravel and YII2 frameworks. You can find more information about YII2 here and Laravel here.
#### This class is inspired by Laravel, CakePHP3 and YII2 frameworks. You can find more information about YII2 here and Laravel here.

<a name="available-methods"></a>
## Available Methods
* [ascii](#ascii)
* [classBasename](#class-basename)
* [slug](#method-slug)
* [length](#method-length)
* [truncate](#method-truncate)
* [substr](#method-substr)
* [ascii](#method-ascii)
* [ordinalize](#method-ordinalize)
* [camelCase](#method-camelCase)
* [studlyCase](#method-studlyCase)
* [endsWith](#method-endsWith)
* [startsWith](#method-startsWith)
* [uuid](#method-uuid)

<a name="method-ascii"></a>
#### `ascii()`
The `ascii` by default converts all characters in provided string into equivalent ASCII characters. The method expects UTF-8 encoding. The character conversion can be controlled using transliteration identifiers which you can pass using the $transliteratorId argument. ICU transliteration identifiers are basically of form ``<source script>:<target script>`` and you can specify multiple conversion pairs separated by ``;``. You can find more info about transliterator identifiers `here <http://userguide.icu-project.org/transforms/general#TOC-Transliterator-Identifiers>`_::

// apple puree
StringHelper::ascii('apple purée');

// Ubermensch (only latin characters are transliterated)
StringHelper::ascii('Übérmensch', 'Latin-ASCII;');

<a name="method-class-basename"></a>
#### `classBasename()`

The `classBasename` returns the class name of the given class with the class' namespace removed:

$class = StringHelper::classBasename('Foo\Bar\Baz');

// Baz

<a name="method-slug"></a>
#### `slug()`
The `slug` function generates a URL friendly "slug" from the given string:
Expand All @@ -31,10 +49,63 @@ The `slug` function generates a URL friendly "slug" from the given string:
// laravel-5-framework

<a name="method-truncate"></a>
#### `truncate()` {#collection-method}
#### `truncate()`

The `truncate` function limits the number of characters in a string. The function accepts a string as its first argument and the maximum number of resulting characters as its second argument:

$value = StringHelper::truncate('The PHP framework for web artisans.', 7);

// The PHP...

<a name="method-ordinalize"></a>
#### `ordinalize()`

The `ordinalize` converts number to its ordinal English form. For example, converts 13 to 13th, 2 to 2nd:

$value = StringHelper::ordinalize(1);

// 1st

<a name="method-camel-case"></a>
#### `camelCase()`

The `camelCase` function converts the given string to `camelCase`:

$camel = StringHelper::camelCase('foo_bar');

// fooBar

<a name="method-studly-case"></a>
#### `studlyCase()`

The `studlyCase` function converts the given string to `StudlyCase`:

$value = StringHelper::studlyCase('foo_bar');

// FooBar

<a name="method-ends-with"></a>
#### `endsWith()`

The `endsWith` function determines if the given string ends with the given value:

$value = StringHelper::endsWith('This is my name', 'name');

// true
<a name="method-starts-with"></a>
#### `startsWith()`

The `startsWith` function determines if the given string begins with the given value:

$value = StringHelper::startsWith('This is my name', 'This');

// true
<a name="method-starts-with"></a>
#### `uuid()`

The `uuid` generate unique identifiers as per **RFC 4122**. The UUID is a 128-bit string in the format of 485fc381-e790-47a3-9794-1337c0a8fe68:

$value = StringHelper::uuid();

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* ArrayToXml
* [Collection](Utils/Collection.md)
* [Encrypter](Utils/Encrypter.md)
* StringHelper
* [StringHelper](Utils/StringHelper.md)
* XmlToArray

Loading

0 comments on commit 2570192

Please sign in to comment.