Passed
Branch 3.2.x (99ec7e)
by Mario
04:20
created

donation_received   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 100
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A get_type() 0 3 1
A get_avatar() 0 3 1
A create_insert_array() 0 12 1
A set_config() 0 3 1
A get_url() 0 3 1
A get_email_template_variables() 0 9 1
A get_item_parent_id() 0 4 1
A get_item_id() 0 3 1
A users_to_query() 0 3 1
A set_user_loader() 0 3 1
1
<?php
2
/**
3
 *
4
 * PayPal Donation extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2015 Skouat
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace skouat\ppde\notification;
12
13
/**
14
 * PayPal Donation notifications class
15
 * This class handles notifications for Admin received donation
16
 */
17
18
abstract class donation_received extends \phpbb\notification\type\base
19
{
20
	/**
21
	 * {@inheritdoc}
22
	 */
23
	public static $notification_option = array();
24
	/** @var \phpbb\config\config */
25
	protected $config;
26
	/** @var \phpbb\user_loader */
27
	protected $user_loader;
28
29
	/**
30
	 * {@inheritdoc}
31
	 */
32
	public static function get_item_id($data)
33
	{
34
		return (int) $data['transaction_id'];
35
	}
36
37
	/**
38
	 * {@inheritdoc}
39
	 */
40
	public static function get_item_parent_id($data)
41
	{
42
		// No parent
43
		return 0;
44
	}
45
46
	/**
47
	 * {@inheritdoc}
48
	 */
49
	public function get_type()
50
	{
51
		return '';
52
	}
53
54
	public function set_config(\phpbb\config\config $config)
55
	{
56
		$this->config = $config;
57
	}
58
59
	public function set_user_loader(\phpbb\user_loader $user_loader)
60
	{
61
		$this->user_loader = $user_loader;
62
	}
63
64
	/**
65
	 * {@inheritdoc}
66
	 */
67
	public function get_avatar()
68
	{
69
		return $this->user_loader->get_avatar($this->get_data('user_from'), false, true);
70
	}
71
72
	/**
73
	 * {@inheritdoc}
74
	 */
75
	public function get_email_template_variables()
76
	{
77
		return array(
78
			'MC_GROSS'       => html_entity_decode($this->get_data('mc_gross'), ENT_COMPAT | ENT_HTML5, 'UTF-8'),
79
			'NET_AMOUNT'     => html_entity_decode($this->get_data('net_amount'), ENT_COMPAT | ENT_HTML5, 'UTF-8'),
80
			'PAYER_EMAIL'    => htmlspecialchars_decode($this->get_data('payer_email')),
81
			'PAYER_USERNAME' => $this->get_data('payer_username'),
82
			'SETTLE_AMOUNT'  => html_entity_decode($this->get_data('settle_amount'), ENT_COMPAT | ENT_HTML5, 'UTF-8'),
83
			'TXN_ID'         => $this->get_data('txn_id'),
84
		);
85
	}
86
87
	/**
88
	 * {@inheritdoc}
89
	 */
90
	public function get_url()
91
	{
92
		return '';
93
	}
94
95
	/**
96
	 * {@inheritdoc}
97
	 */
98
	public function users_to_query()
99
	{
100
		return array($this->get_data('user_from'));
101
	}
102
103
	/**
104
	 * {@inheritdoc}
105
	 */
106
	public function create_insert_array($data, $pre_create_data = array())
107
	{
108
		$this->set_data('mc_gross', $data['mc_gross']);
109
		$this->set_data('net_amount', $data['net_amount']);
110
		$this->set_data('payer_email', $data['payer_email']);
111
		$this->set_data('payer_username', $data['payer_username']);
112
		$this->set_data('settle_amount', $data['settle_amount']);
113
		$this->set_data('transaction_id', $data['transaction_id']);
114
		$this->set_data('txn_id', $data['txn_id']);
115
		$this->set_data('user_from', $data['user_from']);
116
117
		parent::create_insert_array($data, $pre_create_data);
118
	}
119
}
120