Completed
Push — master ( 66319d...49b700 )
by Manu
27:00 queued 12:04
created

SocialAuthTwitterController::redirect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
// SocialAuthTwitterController.php
4
5
namespace App\Http\Controllers;
6
7
use Illuminate\Http\Request;
8
use Socialite;
9
use App\Services\SocialTwitterAccountService;
10
11 View Code Duplication
class SocialAuthTwitterController extends Controller
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
  /**
14
   * Create a redirect method to twitter api.
15
   *
16
   * @return void
17
   */
18
    public function redirect()
19
    {
20
        return Socialite::driver('twitter')->redirect();
21
    }
22
23
    /**
24
     * Return a callback method from twitter api.
25
     *
26
     * @return callback URL from twitter
27
     */
28
    public function callback(SocialTwitterAccountService $service)
29
    {
30
        $user = $service->createOrGetUser(Socialite::driver('twitter')->user());
31
        auth()->login($user);
32
        return redirect()->to('/home');
33
    }
34
}
35