author_info::get_langname()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2018 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\services\topic\driver;
11
12
class author_info implements block_interface
13
{
14
	/** @var\phpbb\language\language */
15
	protected $language;
16
17
	/** @var \phpbb\template\template */
18
	protected $template;
19
20
	/** @var \blitze\sitemaker\services\forum\data */
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\services\forum\data 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...
21
	protected $forum;
22
23
	/* @var \blitze\content\services\helper */
24
	protected $helper;
25
26
	/**
27
	 * Constructor
28
	 *
29
	 * @param \phpbb\language\language					$language			Language Object
30
	 * @param \phpbb\template\template					$template			Template object
31
	 * @param \blitze\sitemaker\services\forum\data		$forum				Forum Data object
32
	 * @param \blitze\content\services\helper			$helper				Content helper object
33
	*/
34
	public function __construct(\phpbb\language\language $language, \phpbb\template\template $template, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper)
35
	{
36
		$this->language = $language;
37
		$this->template = $template;
38
		$this->forum = $forum;
39
		$this->helper = $helper;
40
	}
41
42
	/**
43
	 * @inheritdoc
44
	 */
45
	public function get_name()
46
	{
47
		return 'author_info';
48
	}
49
50
	/**
51
	 * @inheritdoc
52
	 */
53
	public function get_langname()
54
	{
55
		return 'AUTHOR_INFO';
56
	}
57
58
	/**
59
	 * @param \blitze\content\model\entity\type $entity
60
	 * @param array $topic_data
61
	 * @param array $post_data
62
	 * @param array $user_cache
63
	 * @return void
64
	 */
65
	public function show_block(\blitze\content\model\entity\type $entity, array $topic_data, array $post_data, array $user_cache)
66
	{
67
		$forum_id = $topic_data['forum_id'];
68
		$content_langname = $entity->get_content_langname();
69
70
		$this->forum->query()
71
			->fetch_forum($forum_id)
72
			->fetch_topic_poster($topic_data['topic_poster'])
73
			->build(true, true, false);
74
		$user_content_topics = $this->forum->get_topics_count();
75
76
		$this->template->assign_vars(array_merge($user_cache, array(
77
			'S_USER_INFO'			=> true,
78
			'L_USER_ABOUT'			=> $this->language->lang('AUTHOR_INFO_EXPLAIN', $user_cache['username_full'], $user_cache['joined'], $user_content_topics, $content_langname, $user_cache['posts']),
79
			'L_USER_VIEW_ALL'		=> $this->language->lang('VIEW_AUTHOR_CONTENTS', $content_langname, $user_cache['username']),
80
			'L_SEARCH_USER_POSTS'	=> $this->language->lang('SEARCH_USER_POSTS', $user_cache['username']),
81
			'U_SEARCH_CONTENTS'		=> $this->helper->get_search_users_posts_url($forum_id, $user_cache['username']),
82
		)));
83
	}
84
}
85