ShortUrlController::go()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Helldar\ShortUrl\Http\Controllers;
4
5
use Helldar\ShortUrl\Facades\ShortUrl;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Routing\Controller as BaseController;
8
9
class ShortUrlController extends BaseController
10
{
11
    /**
12
     * @param  string  $key
13
     *
14
     * @return \Illuminate\Http\RedirectResponse
15
     */
16 1
    public function go(string $key): RedirectResponse
17
    {
18 1
        $item = ShortUrl::search($key);
19
20 1
        $code = config('short_url.redirect_code');
21
22 1
        return redirect()->away($item->url, $code);
23
    }
24
}
25