friend_request   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 14
lcom 0
cbo 0
dl 0
loc 102
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A get_type() 0 4 1
A __construct() 0 14 1
A is_available() 0 4 1
A get_item_id() 0 4 1
A get_item_parent_id() 0 4 1
A users_to_query() 0 4 1
A find_users_for_notification() 0 10 1
A get_title() 0 5 1
A get_url() 0 4 1
A get_avatar() 0 5 1
A get_redirect_url() 0 4 1
A get_email_template() 0 4 1
A get_email_template_variables() 0 4 1
A create_insert_array() 0 9 1
1
<?php
2
3
namespace florinp\messenger\notification\type;
4
5
class friend_request extends \phpbb\notification\type\base
6
{
7
8
  public function get_type()
9
  {
10
	return 'florinp.messenger.notification.type.friend_request';
11
  }
12
13
  public function __construct(\phpbb\user_loader $user_loader, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)
14
  {
15
	$this->user_loader = $user_loader;
16
	$this->db = $db;
17
	$this->cache = $cache;
18
	$this->user = $user;
19
	$this->auth = $auth;
20
	$this->config = $config;
21
	$this->phpbb_root_path = $phpbb_root_path;
22
	$this->php_ext = $php_ext;
23
	$this->notification_types_table = $notification_types_table;
24
	$this->notifications_table = $notifications_table;
25
	$this->user_notifications_table = $user_notifications_table;
26
  }
27
28
  public static $notification_option = array(
29
	'group'   => 'NOTIFICATION_GROUP_MISCELLANEOUS',
30
  );
31
32
  public function is_available()
33
  {
34
	return true;
35
  }
36
37
  public static function get_item_id($data)
38
  {
39
	return (int)$data['request_id'];
40
  }
41
42
  public static function get_item_parent_id($data)
43
  {
44
	return 0;
45
  }
46
47
  public function users_to_query()
48
  {
49
	return array();
50
  }
51
52
  public function find_users_for_notification($data, $options = array())
53
  {
54
	$options = array_merge(array(
55
	   'ignore_users'      => array(),
56
	), $options);
57
58
	$users = array($data['user_id']);
59
60
	return $this->check_user_notification_options($users, $options);
61
  }
62
63
  public function get_title()
64
  {
65
	$user_id = $this->user_loader->load_user_by_username($this->get_data('sender_username'));
66
	return $this->user->lang('FRIEND_REQUEST_FROM').$this->user_loader->get_username($user_id, 'no_profile');
67
  }
68
69
  public function get_url()
70
  {
71
	return append_sid($this->phpbb_root_path.'ucp.'.$this->php_ext, "i=-florinp-messenger-ucp-ucp_friends_module&amp;mode=requests");
72
  }
73
74
  public function get_avatar()
75
  {
76
	$user_id = $this->user_loader->load_user_by_username($this->get_data('sender_username'));
77
	return $this->user_loader->get_avatar($user_id);
78
  }
79
80
  public function get_redirect_url()
81
  {
82
	return $this->get_url();
83
  }
84
85
  public function get_email_template()
86
  {
87
	return false;
88
  }
89
90
  public function get_email_template_variables()
91
  {
92
	return array();
93
  }
94
95
  public function create_insert_array($data, $pre_create_data = array())
96
  {
97
	$this->set_data('request_id', $data['request_id']);
98
	$this->set_data('sender_id', $data['sender_id']);
99
	$this->set_data('sender_username', $data['sender_username']);
100
	$this->set_data('user_id', $data['user_id']);
101
102
	return parent::create_insert_array($data, $pre_create_data);
103
  }
104
105
106
}
107