BaseAuthorize   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 51
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
authorize() 0 1 ?
A __construct() 0 5 1
A setAction() 0 4 1
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
/**
13
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
14
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
15
 *
16
 * Licensed under The MIT License
17
 * For full copyright and license information, please see the LICENSE.txt
18
 * Redistributions of files must retain the above copyright notice.
19
 *
20
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
21
 * @link          http://cakephp.org CakePHP(tm) Project
22
 * @since         0.10.0
23
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
24
 */
25
26
namespace CakeDC\Api\Service\Auth\Authorize;
27
28
use CakeDC\Api\Service\Action\Action;
29
use Cake\Core\InstanceConfigTrait;
30
use Cake\Http\ServerRequest;
31
32
/**
33
 * Abstract base authorization adapter for Api Auth.
34
 */
35
abstract class BaseAuthorize
36
{
37
38
    use InstanceConfigTrait;
39
40
    /**
41
     * ComponentRegistry instance for getting more components.
42
     *
43
     * @var \CakeDC\Api\Service\Action\Action
44
     */
45
    protected $_action;
46
47
    /**
48
     * Default config for authorize objects.
49
     *
50
     * @var array
51
     */
52
    protected $_defaultConfig = [];
53
54
    /**
55
     * Constructor
56
     *
57
     * @param Action $action An Action instance.
58
     * @param array $config An array of config. This class does not use any config.
59
     */
60 47
    public function __construct(Action $action, array $config = [])
61
    {
62 47
        $this->setAction($action);
63 47
        $this->setConfig($config);
64 47
    }
65
66
    /**
67
     * Checks user authorization.
68
     *
69
     * @param array $user Active user data
70
     * @param \Cake\Http\ServerRequest $request Request instance.
71
     * @return bool
72
     */
73
    abstract public function authorize($user, ServerRequest $request);
74
75
    /**
76
     * Action setter.
77
     *
78
     * @param Action $action An Action instance.
79
     * @return void
80
     */
81 64
    public function setAction(Action $action)
82
    {
83 64
        $this->_action = $action;
84 64
    }
85
}
86