Skip to content

Commit

Permalink
Strings 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jul 3, 2022
1 parent 9e5ce38 commit 921b3cc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 50 deletions.
43 changes: 11 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
name: CI
on: ['push', 'pull_request']
jobs:
phpstan:
name: PHP Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: PHPStan
uses: docker://oskarstark/phpstan-ga
with:
args: analyse src/ -c phpstan.neon
tests:
name: Unit Tests for PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
ci:
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['7.4', '8.0', '8.1']
os: [ubuntu-latest, macos-latest]
php: ['8.1']
dependency-version: [prefer-stable]

steps:
Expand All @@ -27,7 +18,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: fileinfo, spl, json, dom, mbstring, pcntl
extensions: json, mbstring, pcntl
ini-values: disable_functions, error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
Expand All @@ -37,28 +28,17 @@ jobs:
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install PHP 7 dependencies
- name: Install PHP 8.1 dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress
if: "matrix.php < 8"

- name: Install PHP 8 dependencies
if: "matrix.php >= 8"
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress

- name: Run Tests for PHP 7.4
if: "matrix.php == 7.4"
run: ./vendor/bin/pest --coverage

- name: Run Tests for PHP 8.0
if: "matrix.php == 8.0"
run: ./vendor/bin/pest --coverage


- name: PHP Static Analysis for PHP 8.1
run: ./vendor/bin/phpstan

- name: Run Tests for PHP 8.1
if: "matrix.php == 8.1"
run: ./vendor/bin/pest --coverage

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

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Strings Package provide a fluent, object-oriented interface for working with mul
</p>

<p align="center">
<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>
<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>
<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">
<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>
</p>

<br>
Expand Down
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-mbstring": "*",
"glowy/macroable": "^3.0"
Expand All @@ -30,18 +30,21 @@
"src/helpers.php"
]
},
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"pestphp/pest": "^1.21.3",
"phpstan/phpstan": "^1.4.5",
"symfony/var-dumper": "^5.4.9"
},
"config": {
"apcu-autoloader": true,
"optimize-autoloader": true,
"platform-check": false,
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"prefer-stable": true
"require-dev": {
"ext-iconv": "*",
"doctrine/coding-standard": "9.0.0",
"pestphp/pest": "^1.21.1",
"phpstan/phpstan": "^1.8.0",
"symfony/var-dumper": "^6.1.0"
}
}
14 changes: 8 additions & 6 deletions src/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Glowy\Strings;

use Stringable;
use ArrayAccess;
use ArrayIterator;
use Glowy\Macroable\Macroable;
Expand All @@ -23,6 +24,7 @@
use IteratorAggregate;
use OutOfBoundsException;

use function Glowy\Strings\strings;
use function abs;
use function array_count_values;
use function array_merge;
Expand Down Expand Up @@ -117,7 +119,7 @@
*
* @author Sergey Romanenko
*/
class Strings implements ArrayAccess, Countable, IteratorAggregate
class Strings implements ArrayAccess, Countable, IteratorAggregate, Stringable
{
use Macroable;

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

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

Expand All @@ -847,11 +849,11 @@ public function trimLeft(?string $character_mask = null): self
/**
* Strip whitespace (or other characters) from the end of a string.
*
* @param string $character_mask Stripped characters can also be specified using the character_mask parameter.
* @param string|null $character_mask Stripped characters can also be specified using the character_mask parameter.
*
* @return self Returns instance of The Strings class.
*/
public function trimRight(?string $character_mask = null): self
public function trimRight(string|null $character_mask = null): self
{
$this->string = rtrim(...array_merge([$this->string], func_get_args()));

Expand Down Expand Up @@ -2716,7 +2718,7 @@ public function toBoolean(): bool
*
* @return array Return Strings object as array based on a delimiter.
*/
public function toArray(?string $delimiter = null): array
public function toArray(string|null $delimiter = null): array
{
$encoding = $this->encoding;
$string = static::create($this->string, $encoding)->trim()->toString();
Expand Down
4 changes: 3 additions & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

declare(strict_types=1);

namespace Glowy\Strings;

use Glowy\Strings\Strings;

if (! function_exists('strings')) {
Expand All @@ -25,7 +27,7 @@
* @param mixed $string Value to modify, after being cast to string. Default: ''
* @param mixed $encoding The character encoding. Default: UTF-8
*/
function strings($string = '', $encoding = 'UTF-8'): Strings
function strings($string = '', $encoding = 'UTF-8'): \Glowy\Strings\Strings
{
return new Strings($string, $encoding);
}
Expand Down
1 change: 1 addition & 0 deletions tests/StringsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
declare(strict_types=1);

use Glowy\Strings\Strings;
use function Glowy\Strings\strings;

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

0 comments on commit 921b3cc

Please sign in to comment.