Skip to content

Commit

Permalink
Merge pull request #87 from bvtterfly/patch-1
Browse files Browse the repository at this point in the history
Fix LaravelVersion
  • Loading branch information
freekmurze authored Apr 14, 2022
2 parents d8c6991 + e199aea commit 924d1ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Support/LaravelDocumentationLinkFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function findLinkForThrowable(Throwable $throwable): ?string
$throwable = $throwable->getPrevious();
}

$majorVersion = explode('.', app()->version())[0];
$majorVersion = LaravelVersion::major();

if (str_contains($throwable->getMessage(), Collection::class)) {
return "https://laravel.com/docs/{$majorVersion}.x/collections#available-methods";
Expand Down
2 changes: 1 addition & 1 deletion src/Support/LaravelVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class LaravelVersion
{
public static function major(): string
{
return substr(app()->version(), 0, 1);
return explode('.', app()->version())[0];
}
}
3 changes: 2 additions & 1 deletion tests/Support/LaravelDocumentationLinkFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Auth\AuthenticationException;
use Spatie\LaravelIgnition\Support\LaravelDocumentationLinkFinder;
use Spatie\LaravelIgnition\Support\LaravelVersion;

beforeEach(function () {
$this->finder = new LaravelDocumentationLinkFinder();
Expand All @@ -10,7 +11,7 @@
it('can find a link for a laravel exception', function () {
$link = $this->finder->findLinkForThrowable(new AuthenticationException());

$majorVersion = explode('.', app()->version())[0];
$majorVersion = LaravelVersion::major();

expect($link)->toEqual("https://laravel.com/docs/{$majorVersion}.x/authentication");
});

0 comments on commit 924d1ae

Please # to comment.