Completed
Push — develop ( cc7114...ef0a0d )
by Daniel
08:51
created

setup   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A is_enabled() 0 4 2
A get_access_key() 0 4 1
A set_js_vars() 0 7 1
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2017 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\services\filemanager;
11
12
/**
13
* @package sitemaker
14
*/
15
class setup
16
{
17
	/** @var \phpbb\auth\auth */
18
	protected $auth;
19
20
	/** @var \phpbb\config\config */
21
	protected $config;
22
23
	/** @var \phpbb\template\template */
24
	protected $template;
25
26
	/**
27
	 * Constructor
28
	 *
29
	 * @param \phpbb\auth\auth				$auth				Auth object
30
	 * @param \phpbb\config\config			$config				Config object
31
	 * @param \phpbb\template\template		$template			Template object
32
	 */
33 12
	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\template $template)
34
	{
35 12
		$this->auth = $auth;
36 12
		$this->config = $config;
37 12
		$this->template = $template;
38 12
	}
39
40
	/**
41
	 * @return bool
42
	 */
43 4
	public function is_enabled()
44
	{
45 4
		return $this->config['sm_filemanager'] && $this->auth->acl_get('u_sm_filemanager');
46
	}
47
48
	/**
49
	 * @return void
50
	 */
51 4
	public function get_access_key()
52
	{
53 4
		return sha1($this->user->data['user_form_salt'] . 'filemanager');
0 ignored issues
show
Bug introduced by
The property user does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
	}
55
56
	/**
57
	 * @return array
58
	 */
59 4
	public function set_js_vars()
60
	{
61 4
		$this->template->assign_vars(array(
62 4
			'UA_FILEMANAGER'	=> $this->is_enabled(),
63 4
			'UA_RF_ACCESS_KEY'	=> $this->get_access_key(),
64 4
		));
65 4
	}
66
}
67