Passed
Push — master ( f3cada...70e388 )
by Vince
02:31
created

system::userCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 16
rs 9.9332

1 Method

Rating   Name   Duplication   Size   Complexity  
A system::tokenAccessToken() 0 2 1
1
<?php
2
3
/**
4
 * ==================================
5
 * Responsible PHP API
6
 * ==================================
7
 *
8
 * @link Git https://github.com/vince-scarpa/responsibleAPI.git
9
 *
10
 * @api Responible API
11
 * @package responsible\core\endpoints
12
 *
13
 * @author Vince scarpa <[email protected]>
14
 *
15
 */
16
namespace responsible\core\endpoints;
17
18
use responsible\core\endpoints;
19
use responsible\core\exception;
20
use responsible\core\headers;
21
use responsible\responsible;
22
23
class system extends map
24
{
25
    /**
26
     * [$settings]
27
     * @var array
28
     */
29
    private $settings = [];
30
31
    /**
32
     * [$RESPONSE Set the internal system response]
33
     * @var array
34
     */
35
    protected $RESPONSE;
36
37
    /**
38
     * [__construct Silence..]
39
     */
40
    public function __construct()
41
    {}
42
43
    /**
44
     * [settings Inherited settings]
45
     * @return void
46
     */
47
    public function settings(array $settings)
48
    {
49
        $this->settings = $settings;
50
    }
51
52
    /**
53
     * [headerMethods]
54
     * @return void
55
     */
56
    public function headerMethods()
57
    {
58
        $headers = new headers\header;
59
        $headers->setAllowedMethods(
60
            ['GET', 'POST', 'PATCH']
61
        );
62
    }
63
64
    /**
65
     * [tokenAccess_token Empty function, not handled in this class. See header for method]
66
     * @see [header->accessCredentialsHeaders()]
67
     * @return void
68
     */
69
    public function tokenAccessToken()
70
    {}
71
72
    /**
73
     * [run Get the system response]
74
     * @return object|null
75
     */
76
    public function run()
77
    {
78
        /**
79
         * Method exists
80
         */
81
        if (isset($this->settings['model']['method'])) {
82
            $method = $this->settings['model']['method'];
83
            if (method_exists($this, $method)) {
84
                return call_user_func(array($this, $method));
85
            }
86
        }
87
88
        /**
89
         * Method doesn't exists throw an application error
90
         */
91
        (new exception\errorException)
92
            ->message('The requested method `' . $this->settings['model']['method'] . '` dosen\'t exist. Please read the documentation on supported request types.')
93
            ->error('APPLICATION_ERROR');
94
    }
95
}
96