Skip to content

Commit

Permalink
Added static start() helper to Regex
Browse files Browse the repository at this point in the history
  • Loading branch information
rudashi committed Mar 9, 2024
1 parent 90ccc25 commit f767f1e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ public static function for(string $string): FluentBuilder
return static::build()->setContext($string);
}

public static function start(): FluentBuilder
{
return static::build()->startOfLine();
}

public static function startOfLine(): FluentBuilder
{
return static::start();
}

public function newBuilder(): FluentBuilder
{
return new FluentBuilder();
Expand Down
16 changes: 16 additions & 0 deletions tests/Unit/RegexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@
expect($data)
->toBeInstanceOf(FluentBuilder::class);
});

it('can create a Builder at the start of the string', function () {
$data = Regex::start();

expect($data)
->toBeInstanceOf(FluentBuilder::class)
->get()->toBe('/^/');
});

test('call `startOfLine` - `start()` alias ', function () {
$data = Regex::startOfLine();

expect($data)
->toBeInstanceOf(FluentBuilder::class)
->get()->toBe('/^/');
});

0 comments on commit f767f1e

Please sign in to comment.