base   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 48
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A avatars_enabled() 0 3 3
A is_enabled() 0 3 2
A last_post_enabled() 0 3 1
1
<?php
2
/**
3
 *
4
 * Topic Preview
5
 *
6
 * @copyright (c) 2013 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\topicpreview\core;
12
13
use phpbb\config\config;
0 ignored issues
show
Bug introduced by
The type phpbb\config\config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use phpbb\user;
0 ignored issues
show
Bug introduced by
The type phpbb\user was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
class base
17
{
18
	/** @var config */
19
	protected $config;
20
21
	/** @var user */
22
	protected $user;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param config $config Config object
28
	 * @param user   $user   User object
29
	 */
30 12
	public function __construct(config $config, user $user)
31
	{
32 12
		$this->config = $config;
33 12
		$this->user = $user;
34 12
	}
35
36
	/**
37
	 * Show topic previews, given current board and user configurations
38
	 *
39
	 * @return bool
40
	 */
41 12
	public function is_enabled()
42
	{
43 12
		return !empty($this->config['topic_preview_limit']) && !empty($this->user->data['user_topic_preview']);
44
	}
45
46
	/**
47
	 * Show avatars, given current board and user configurations
48
	 *
49
	 * @return bool
50
	 */
51 7
	public function avatars_enabled()
52
	{
53 7
		return $this->config['topic_preview_avatars'] && $this->config['allow_avatar'] && $this->user->optionget('viewavatars');
54
	}
55
56
	/**
57
	 * Show last post text, given current board configuration
58
	 *
59
	 * @return bool
60
	 */
61 11
	public function last_post_enabled()
62
	{
63 11
		return (bool) $this->config['topic_preview_last_post'];
64
	}
65
}
66