Passed
Pull Request — master (#124)
by Arman
06:03 queued 02:57
created

csrf()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.0
13
 */
14
15
use Quantum\Libraries\Session\SessionManager;
16
use Quantum\Libraries\Asset\AssetManager;
17
use Quantum\Libraries\Cache\CacheManager;
18
use Quantum\Libraries\Auth\AuthManager;
19
use Quantum\Libraries\Session\Session;
20
use Quantum\Libraries\Cookie\Cookie;
21
use Quantum\Libraries\Mailer\Mailer;
22
use Quantum\Libraries\Auth\ApiAuth;
23
use Quantum\Libraries\Auth\WebAuth;
24
use Quantum\Libraries\Cache\Cache;
25
use Quantum\Libraries\Csrf\Csrf;
26
use Quantum\Hooks\HookManager;
27
use Quantum\Di\Di;
28
29
/**
30
 * Gets the session handler
31
 * @return Session
32
 * @throws ReflectionException
33
 * @throws \Quantum\Exceptions\ConfigException
34
 * @throws \Quantum\Exceptions\DatabaseException
35
 * @throws \Quantum\Exceptions\DiException
36
 * @throws \Quantum\Exceptions\SessionException
37
 * @throws \Quantum\Exceptions\LangException
38
 */
39
function session(): Session
40
{
41
    return SessionManager::getHandler();
42
}
43
44
/**
45
 * Gets cookie handler
46
 * @return Cookie
47
 */
48
function cookie(): Cookie
49
{
50
    return Cookie::getInstance($_COOKIE);
51
}
52
53
/**
54
 * Gets the Auth handler
55
 * @return ApiAuth|WebAuth
56
 * @throws ReflectionException
57
 * @throws \Quantum\Exceptions\AuthException
58
 * @throws \Quantum\Exceptions\ConfigException
59
 * @throws \Quantum\Exceptions\DiException
60
 */
61
function auth()
62
{
63
    return AuthManager::getHandler();
64
}
65
66
/**
67
 * Gets the Mail instance
68
 * @return Mailer
69
 * @throws ReflectionException
70
 * @throws \Quantum\Exceptions\DiException
71
 */
72
function mailer(): Mailer
73
{
74
    return Di::get(Mailer::class);
75
}
76
77
/**
78
 * Gets the AssetManager instance
79
 * @return AssetManager|null
80
 */
81
function asset(): ?AssetManager
82
{
83
    return AssetManager::getInstance();
84
}
85
86
/**
87
 * Gets the HookManager instance
88
 * @return HookManager
89
 */
90
function hook(): HookManager
91
{
92
    return HookManager::getInstance();
93
}
94
95
/**
96
 * Gets the Cache handler
97
 * @return Cache
98
 * @throws ReflectionException
99
 * @throws \Quantum\Exceptions\AppException
100
 * @throws \Quantum\Exceptions\ConfigException
101
 * @throws \Quantum\Exceptions\DiException
102
 */
103
function cache(): Cache
104
{
105
    return CacheManager::getHandler();
106
}
107
108
/**
109
 * Gets the Csrf instance
110
 * @return Csrf
111
 */
112
function csrf(): Csrf
113
{
114
    return Csrf::getInstance();
115
}
116