Skip to content

Commit

Permalink
feat(strings): change signature of method increment
Browse files Browse the repository at this point in the history
BREAKING CHANGES

- signature of method `increment` changed.
  • Loading branch information
Awilum committed Jun 7, 2022
1 parent 906b904 commit 9e5ce38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ public function random(int $length = 64, string $keyspace = '0123456789abcdefghi
/**
* Add's _1 to a string or increment the ending number to allow _2, _3, etc.
*
* @param int $first Start with
* @param string $separator Separator
* @param int $first Start with
*
* @return self Returns instance of The Strings class.
*/
public function increment(int $first = 1, string $separator = '_'): self
public function increment(string $separator = '_', int $first = 1): self
{
preg_match('/(.+)' . $separator . '([0-9]+)$/', $this->string, $match);

Expand Down
4 changes: 2 additions & 2 deletions tests/StringsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@

test('test increment() method', function (): void {
$this->assertEquals('page_2', Strings::create('page_1')->increment());
$this->assertEquals('page_3', Strings::create('page')->increment(3));
$this->assertEquals('page-3', Strings::create('page')->increment(3, '-'));
$this->assertEquals('page_3', Strings::create('page')->increment('_', 3));
$this->assertEquals('page-3', Strings::create('page')->increment('-', 3));
});


Expand Down

0 comments on commit 9e5ce38

Please sign in to comment.