Completed
Push — master ( cb5a9c...81e444 )
by ARCANEDEV
03:29
created

ApiController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 45
ccs 0
cts 16
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A check() 0 13 2
1
<?php namespace Arcanesoft\Auth\Http\Controllers\Front;
2
3
use Arcanesoft\Auth\Bases\Controller;
4
use Illuminate\Contracts\Auth\Guard;
5
6
/**
7
 * Class     ApiController
8
 *
9
 * @package  Arcanesoft\Auth\Http\Controllers\Front
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class ApiController extends Controller
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * @var \Illuminate\Contracts\Auth\Guard
20
     */
21
    private $auth;
22
23
    /* ------------------------------------------------------------------------------------------------
24
     |  Constructor
25
     | ------------------------------------------------------------------------------------------------
26
     */
27
    /**
28
     * ApiController constructor.
29
     *
30
     * @param  \Illuminate\Contracts\Auth\Guard  $auth
31
     */
32
    public function __construct(Guard $auth)
33
    {
34
        parent::__construct();
35
36
        $this->auth = $auth;
37
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Main Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    public function check()
44
    {
45
        self::onlyAjax();
46
47
        if ( ! $this->auth->check()) {
48
            abort(404, 'Page not found');
49
        }
50
51
        return [
52
            'success' => true,
53
            'message' => 'User authenticated.',
54
        ];
55
    }
56
}
57