Skip to content

Commit 31f8c84

Browse files
committed
- update README.md
- change some methods name
1 parent cde4aca commit 31f8c84

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# Yii2 string helpers
22

3+
[![Build Status](https://travis-ci.org/hyperia-sk/yii2-string-helpers.svg)](https://travis-ci.org/hyperia-sk/yii2-secure-headers) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hyperia-sk/yii2-string-helpers/master/LICENSE)
4+
5+
> Extension for Yii2 string helpers
6+
7+
## Installation
8+
9+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
10+
11+
Either run
12+
13+
```shell
14+
composer require hyperia/yii2-string-helpers:"^1.0"
15+
```
16+
17+
or add
18+
19+
```
20+
"hyperia/yii2-string-helpers": "^1.0"
21+
```
22+
23+
to the require section of your composer.json.
24+
25+
## Available Methods
26+
27+
- contains
28+
- isLonger
29+
- isShorter
30+
- length
31+
- toLower
32+
- toUpper
33+
- firstCharToUpper
34+
- removeAccent
35+
36+
## Usage
37+
38+
```php
39+
use hyperia\helpers\StringHelper;
40+
41+
echo StringHelper::isLonger('This is test string', 12); // 1
42+
echo StrinhHelper::removeAccent('Ħí ŧħə®ë, юßť å test!'); // Hi there, jusst a test!
43+
echo StringHelper::contains('is', 'This is test string'); // 1
44+
```
45+
346
## Tests
447

548
change `phpunit.xml.dist` to `phpunit.xml` and run

src/StringHelper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function length($string, $encoding = 'UTF-8')
7171
* @param string $encoding
7272
* @return string
7373
*/
74-
public static function strtolower($string, $encoding = 'UTF-8')
74+
public static function toLower($string, $encoding = 'UTF-8')
7575
{
7676
return mb_strtolower($string, $encoding);
7777
}
@@ -84,7 +84,7 @@ public static function strtolower($string, $encoding = 'UTF-8')
8484
* @param string $encoding
8585
* @return string
8686
*/
87-
public static function strtoupper($string, $encoding = 'UTF-8')
87+
public static function toUpper($string, $encoding = 'UTF-8')
8888
{
8989
return mb_strtoupper($string, $encoding);
9090
}
@@ -97,13 +97,13 @@ public static function strtoupper($string, $encoding = 'UTF-8')
9797
* @param string $encoding
9898
* @return string
9999
*/
100-
public static function ucfirst($string, $encoding = 'UTF-8')
100+
public static function firstCharToUpper($string, $encoding = 'UTF-8')
101101
{
102102
$strlen = static::length($string, $encoding);
103103
$firstChar = mb_substr($string, 0, 1, $encoding);
104104
$then = mb_substr($string, 1, $strlen - 1, $encoding);
105105

106-
return mb_strtoupper($firstChar, $encoding) . $then;
106+
return static::toUpper($firstChar, $encoding) . $then;
107107
}
108108

109109
/**

tests/StringHelperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ public function testLength($test_string)
122122
/**
123123
* @dataProvider testStringProvider
124124
*/
125-
public function testStrtolower($test_string)
125+
public function testToLower($test_string)
126126
{
127-
$this->assertEquals('ščťýľárt4569', StringHelper::strtolower($test_string));
127+
$this->assertEquals('ščťýľárt4569', StringHelper::toLower($test_string));
128128
}
129129

130130
/**
131131
* @dataProvider testStringProvider
132132
*/
133-
public function testStrtoupper($test_string)
133+
public function testToUpper($test_string)
134134
{
135-
$this->assertEquals('ŠČŤÝĽÁRT4569', StringHelper::strtoupper($test_string));
135+
$this->assertEquals('ŠČŤÝĽÁRT4569', StringHelper::toUpper($test_string));
136136
}
137137

138138
/**
139139
* @dataProvider testStringProvider
140140
*/
141-
public function testUcfirst($test_string)
141+
public function testFirstCharToUpper($test_string)
142142
{
143-
$this->assertEquals('ŠčŤýĽÁrT4569', StringHelper::ucfirst($test_string));
143+
$this->assertEquals('ŠčŤýĽÁrT4569', StringHelper::firstCharToUpper($test_string));
144144
}
145145

146146
public function testStringProvider()

0 commit comments

Comments
 (0)