Auth   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 99
ccs 52
cts 52
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A autorun() 0 6 1
A _setUser() 0 17 2
A _setPermission() 0 34 2
A _setTable() 0 12 1
1
<?php
2
namespace Redaxscript\Bootstrap;
3
4
use Redaxscript\Auth as BaseAuth;
5
6
/**
7
 * children class to boot the auth
8
 *
9
 * @since 3.1.0
10
 *
11
 * @package Redaxscript
12
 * @category Bootstrap
13
 * @author Henry Ruhs
14
 */
15
16
class Auth extends BootstrapAbstract
17
{
18
	/**
19
	 * automate run
20
	 *
21
	 * @since 3.1.0
22
	 */
23
24 2
	public function autorun() : void
25
	{
26 2
		$this->_setUser();
27 2
		$this->_setPermission();
28 2
		$this->_setTable();
29 2
	}
30
31
	/**
32
	 * set the user
33
	 *
34
	 * @since 3.1.0
35
	 */
36
37 2
	protected function _setUser() : void
38
	{
39 2
		$auth = new BaseAuth($this->_request);
40 2
		$auth->init();
41
42
		/* set the registry */
43
44 2
		if ($auth->getStatus() === 1)
45
		{
46 1
			$this->_registry->set('myId', $auth->getUser('id'));
47 1
			$this->_registry->set('myName', $auth->getUser('name'));
48 1
			$this->_registry->set('myUser', $auth->getUser('user'));
49 1
			$this->_registry->set('myEmail', $auth->getUser('email'));
50 1
			$this->_registry->set('myLanguage', $auth->getUser('language'));
51 1
			$this->_registry->set('myGroups', $auth->getUser('groups'));
52
		}
53 2
	}
54
55
	/**
56
	 * set the permission
57
	 *
58
	 * @since 3.1.0
59
	 */
60
61 2
	protected function _setPermission() : void
62
	{
63 2
		$auth = new BaseAuth($this->_request);
64 2
		$auth->init();
65
66
		/* set the registry */
67
68 2
		if ($auth->getStatus() === 1)
69
		{
70 1
			$this->_registry->set('categoriesNew', $auth->getPermissionNew('categories'));
71 1
			$this->_registry->set('categoriesEdit', $auth->getPermissionEdit('categories'));
72 1
			$this->_registry->set('categoriesDelete', $auth->getPermissionDelete('categories'));
73 1
			$this->_registry->set('articlesNew', $auth->getPermissionNew('articles'));
74 1
			$this->_registry->set('articlesEdit', $auth->getPermissionEdit('articles'));
75 1
			$this->_registry->set('articlesDelete', $auth->getPermissionDelete('articles'));
76 1
			$this->_registry->set('extrasNew', $auth->getPermissionNew('extras'));
77 1
			$this->_registry->set('extrasEdit', $auth->getPermissionEdit('extras'));
78 1
			$this->_registry->set('extrasDelete', $auth->getPermissionDelete('extras'));
79 1
			$this->_registry->set('commentsNew', $auth->getPermissionNew('comments'));
80 1
			$this->_registry->set('commentsEdit', $auth->getPermissionEdit('comments'));
81 1
			$this->_registry->set('commentsDelete', $auth->getPermissionDelete('comments'));
82 1
			$this->_registry->set('groupsNew', $auth->getPermissionNew('groups'));
83 1
			$this->_registry->set('groupsEdit', $auth->getPermissionEdit('groups'));
84 1
			$this->_registry->set('groupsDelete', $auth->getPermissionDelete('groups'));
85 1
			$this->_registry->set('usersNew', $auth->getPermissionNew('users'));
86 1
			$this->_registry->set('usersEdit', $auth->getPermissionEdit('users'));
87 1
			$this->_registry->set('usersDelete', $auth->getPermissionDelete('users'));
88 1
			$this->_registry->set('modulesInstall', $auth->getPermissionInstall('modules'));
89 1
			$this->_registry->set('modulesEdit', $auth->getPermissionEdit('modules'));
90 1
			$this->_registry->set('modulesUninstall', $auth->getPermissionUninstall('modules'));
91 1
			$this->_registry->set('settingsEdit', $auth->getPermissionEdit('settings'));
92
		}
93 2
		$this->_registry->set('filter', $auth->getFilter());
94 2
	}
95
96
	/**
97
	 * set the table
98
	 *
99
	 * @since 3.1.0
100
	 */
101
102 2
	protected function _setTable() : void
103
	{
104 2
		$tableParameter = $this->_registry->get('tableParameter');
105
106
		/* set the registry */
107
108 2
		$this->_registry->set('tableNew', $this->_registry->get($tableParameter . 'New'));
109 2
		$this->_registry->set('tableInstall', $this->_registry->get($tableParameter . 'Install'));
110 2
		$this->_registry->set('tableEdit', $this->_registry->get($tableParameter . 'Edit'));
111 2
		$this->_registry->set('tableDelete', $this->_registry->get($tableParameter . 'Delete'));
112 2
		$this->_registry->set('tableUninstall', $this->_registry->get($tableParameter . 'Uninstall'));
113 2
	}
114
}
115