Skip to content

Commit 921b3cc

Browse files
committed
Strings 5.0.0
1 parent 9e5ce38 commit 921b3cc

File tree

6 files changed

+35
-50
lines changed

6 files changed

+35
-50
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
name: CI
22
on: ['push', 'pull_request']
33
jobs:
4-
phpstan:
5-
name: PHP Static Analysis
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v2
9-
- name: PHPStan
10-
uses: docker://oskarstark/phpstan-ga
11-
with:
12-
args: analyse src/ -c phpstan.neon
13-
tests:
14-
name: Unit Tests for PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
4+
ci:
5+
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
156
runs-on: ${{ matrix.os }}
167
strategy:
178
matrix:
18-
os: [ubuntu-latest, macos-latest, windows-latest]
19-
php: ['7.4', '8.0', '8.1']
9+
os: [ubuntu-latest, macos-latest]
10+
php: ['8.1']
2011
dependency-version: [prefer-stable]
2112

2213
steps:
@@ -27,7 +18,7 @@ jobs:
2718
uses: shivammathur/setup-php@v2
2819
with:
2920
php-version: ${{ matrix.php }}
30-
extensions: fileinfo, spl, json, dom, mbstring, pcntl
21+
extensions: json, mbstring, pcntl
3122
ini-values: disable_functions, error_reporting=E_ALL
3223
tools: composer:v2
3324
coverage: xdebug
@@ -37,28 +28,17 @@ jobs:
3728
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3829
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
3930
40-
- name: Install PHP 7 dependencies
31+
- name: Install PHP 8.1 dependencies
4132
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress
42-
if: "matrix.php < 8"
43-
44-
- name: Install PHP 8 dependencies
45-
if: "matrix.php >= 8"
46-
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress
47-
48-
- name: Run Tests for PHP 7.4
49-
if: "matrix.php == 7.4"
50-
run: ./vendor/bin/pest --coverage
51-
52-
- name: Run Tests for PHP 8.0
53-
if: "matrix.php == 8.0"
54-
run: ./vendor/bin/pest --coverage
55-
33+
34+
- name: PHP Static Analysis for PHP 8.1
35+
run: ./vendor/bin/phpstan
36+
5637
- name: Run Tests for PHP 8.1
57-
if: "matrix.php == 8.1"
5838
run: ./vendor/bin/pest --coverage
5939

6040
support:
61-
needs: [phpstan, tests]
41+
needs: [ci]
6242
name: Discord Notification
6343
runs-on: ubuntu-latest
6444
steps:
@@ -68,4 +48,3 @@ jobs:
6848
with:
6949
webhook: ${{ secrets.WEBHOOK_TOKEN }}
7050
message: "**❤️ SUPPORT ONGOING DEVELOPMENT**\n➡️ https://github.com/Awilum#support-me"
71-

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ Strings Package provide a fluent, object-oriented interface for working with mul
44
</p>
55

66
<p align="center">
7-
<a href="https://github.com/glowyphp/strings/releases"><img alt="Version" src="https://img.shields.io/github/release/glowyphp/strings.svg?label=version&style=for-the-badge"></a>
8-
<a href="https://github.com/glowyphp/strings"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge" alt="License"></a>
9-
<a href="https://packagist.org/packages/glowy/strings"><img src="https://poser.pugx.org/glowy/strings/downloads?style=for-the-badge" alt="Total downloads"></a><img src="http://poser.pugx.org/glowy/strings/require/php?style=for-the-badge">
7+
<img src="https://img.shields.io/badge/license-MIT-blue.svg?label=License" alt="License MIT"> <a href="https://packagist.org/packages/glowy/strings"><img src="https://poser.pugx.org/glowy/strings/downloads" alt="Total downloads"></a> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/glowyphp/strings?label=Stars"> <img alt="GitHub forks" src="https://img.shields.io/github/forks/glowyphp/strings?label=Forks"> <a href="https://hitsofcode.com"><img alt="Hits of Code" src="https://hitsofcode.com/github/glowyphp/strings?branch=4.x"></a> <a href="https://discord.gg/ewQkqgfBAc"><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&label=Discord%20Chat" alt="Discord"></a>
108
</p>
119

1210
<br>

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.4 || ^8.0",
20+
"php": "^8.1",
2121
"ext-json": "*",
2222
"ext-mbstring": "*",
2323
"glowy/macroable": "^3.0"
@@ -30,18 +30,21 @@
3030
"src/helpers.php"
3131
]
3232
},
33-
"require-dev": {
34-
"doctrine/coding-standard": "9.0.0",
35-
"pestphp/pest": "^1.21.3",
36-
"phpstan/phpstan": "^1.4.5",
37-
"symfony/var-dumper": "^5.4.9"
38-
},
3933
"config": {
34+
"apcu-autoloader": true,
35+
"optimize-autoloader": true,
36+
"platform-check": false,
4037
"sort-packages": true,
4138
"allow-plugins": {
4239
"pestphp/pest-plugin": true,
4340
"dealerdirect/phpcodesniffer-composer-installer": true
4441
}
4542
},
46-
"prefer-stable": true
43+
"require-dev": {
44+
"ext-iconv": "*",
45+
"doctrine/coding-standard": "9.0.0",
46+
"pestphp/pest": "^1.21.1",
47+
"phpstan/phpstan": "^1.8.0",
48+
"symfony/var-dumper": "^6.1.0"
49+
}
4750
}

src/Strings.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Glowy\Strings;
1515

16+
use Stringable;
1617
use ArrayAccess;
1718
use ArrayIterator;
1819
use Glowy\Macroable\Macroable;
@@ -23,6 +24,7 @@
2324
use IteratorAggregate;
2425
use OutOfBoundsException;
2526

27+
use function Glowy\Strings\strings;
2628
use function abs;
2729
use function array_count_values;
2830
use function array_merge;
@@ -117,7 +119,7 @@
117119
*
118120
* @author Sergey Romanenko
119121
*/
120-
class Strings implements ArrayAccess, Countable, IteratorAggregate
122+
class Strings implements ArrayAccess, Countable, IteratorAggregate, Stringable
121123
{
122124
use Macroable;
123125

@@ -823,7 +825,7 @@ public function indexOfLast(string $needle, int $offset = 0, bool $caseSensitive
823825
*
824826
* @return self Returns instance of The Strings class.
825827
*/
826-
public function trim(?string $character_mask = null): self
828+
public function trim(string|null $character_mask = null): self
827829
{
828830
$this->string = trim(...array_merge([$this->string], func_get_args()));
829831

@@ -837,7 +839,7 @@ public function trim(?string $character_mask = null): self
837839
*
838840
* @return self Returns instance of The Strings class.
839841
*/
840-
public function trimLeft(?string $character_mask = null): self
842+
public function trimLeft(string|null $character_mask = null): self
841843
{
842844
$this->string = ltrim(...array_merge([$this->string], func_get_args()));
843845

@@ -847,11 +849,11 @@ public function trimLeft(?string $character_mask = null): self
847849
/**
848850
* Strip whitespace (or other characters) from the end of a string.
849851
*
850-
* @param string $character_mask Stripped characters can also be specified using the character_mask parameter.
852+
* @param string|null $character_mask Stripped characters can also be specified using the character_mask parameter.
851853
*
852854
* @return self Returns instance of The Strings class.
853855
*/
854-
public function trimRight(?string $character_mask = null): self
856+
public function trimRight(string|null $character_mask = null): self
855857
{
856858
$this->string = rtrim(...array_merge([$this->string], func_get_args()));
857859

@@ -2716,7 +2718,7 @@ public function toBoolean(): bool
27162718
*
27172719
* @return array Return Strings object as array based on a delimiter.
27182720
*/
2719-
public function toArray(?string $delimiter = null): array
2721+
public function toArray(string|null $delimiter = null): array
27202722
{
27212723
$encoding = $this->encoding;
27222724
$string = static::create($this->string, $encoding)->trim()->toString();

src/helpers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
declare(strict_types=1);
1313

14+
namespace Glowy\Strings;
15+
1416
use Glowy\Strings\Strings;
1517

1618
if (! function_exists('strings')) {
@@ -25,7 +27,7 @@
2527
* @param mixed $string Value to modify, after being cast to string. Default: ''
2628
* @param mixed $encoding The character encoding. Default: UTF-8
2729
*/
28-
function strings($string = '', $encoding = 'UTF-8'): Strings
30+
function strings($string = '', $encoding = 'UTF-8'): \Glowy\Strings\Strings
2931
{
3032
return new Strings($string, $encoding);
3133
}

tests/StringsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
declare(strict_types=1);
1313

1414
use Glowy\Strings\Strings;
15+
use function Glowy\Strings\strings;
1516

1617
test('test __construct() method', function (): void {
1718
$this->assertInstanceOf(Strings::class, new Strings());

0 commit comments

Comments
 (0)