Passed
Pull Request — develop-3.2.x (#54)
by Mario
02:28
created

admin_donors_controller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 7
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * PayPal Donation extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 Skouat
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace skouat\ppde\controller;
12
13
use Symfony\Component\DependencyInjection\ContainerInterface;
14
15
/**
16
 * Class admin_donors_controller
17
 *
18
 * @property \phpbb\config\config     config             Config object
19
 * @property ContainerInterface       container          Service container interface
20
 * @property \phpbb\request\request   request            Request object.
21
 * @property \phpbb\template\template template           Template object
22
 *
23
 * @package skouat\ppde\controller
24
 */
25
class admin_donors_controller extends admin_main
0 ignored issues
show
Bug introduced by
The type skouat\ppde\controller\admin_main 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...
26
{
27
	protected $ppde_entity_transactions;
28
	protected $ppde_main_controller;
29
	protected $ppde_operator_transactions;
30
31
	/**
32
	 * constructor
33
	 *
34
	 * @param \phpbb\config\config                    $config                     Config object
35
	 * @param ContainerInterface                      $container                  Service container interface
36
	 * @param \skouat\ppde\entity\transactions        $ppde_entity_transactions   Entity object
37
	 * @param \skouat\ppde\controller\main_controller $ppde_main_controller       Main controller object
38
	 * @param \skouat\ppde\operators\transactions     $ppde_operator_transactions Operator object
39
	 * @param \phpbb\request\request                  $request                    Request object
40
	 * @param \phpbb\template\template                $template                   Template object
41
	 */
42
	public function __construct(\phpbb\config\config $config, ContainerInterface $container, \skouat\ppde\entity\transactions $ppde_entity_transactions, \skouat\ppde\controller\main_controller $ppde_main_controller, \skouat\ppde\operators\transactions $ppde_operator_transactions, \phpbb\request\request $request, \phpbb\template\template $template)
43
	{
44
		$this->config = $config;
45
		$this->container = $container;
46
		$this->ppde_entity_transactions = $ppde_entity_transactions;
47
		$this->ppde_main_controller = $ppde_main_controller;
48
		$this->ppde_operator_transactions = $ppde_operator_transactions;
49
		$this->request = $request;
50
		$this->template = $template;
51
		parent::__construct(
52
			'donors',
53
			'PPDE_DD',
54
			''
55
		);
56
	}
57
58
	/**
59
	 * Display the donors list
60
	 *
61
	 * @return void
62
	 * @access public
63
	 */
64
	public function display_donors()
65
	{
66
		$start = $this->request->variable('start', 0);
67
68
		// Build SQL Query
69
		$get_donorlist_sql_ary = $this->ppde_operator_transactions->get_sql_donorlist_ary(false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type integer expected by parameter $max_txn_id of skouat\ppde\operators\tr...get_sql_donorlist_ary(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
		$get_donorlist_sql_ary = $this->ppde_operator_transactions->get_sql_donorlist_ary(/** @scrutinizer ignore-type */ false);
Loading history...
70
		// adds fields to the table schema needed by entity->import()
71
		$additional_table_schema = array(
72
			'item_username'    => array('name' => 'username', 'type' => 'string'),
73
			'item_user_colour' => array('name' => 'user_colour', 'type' => 'string'),
74
			'item_amount'      => array('name' => 'amount', 'type' => 'float'),
75
			'item_max_txn_id'  => array('name' => 'max_txn_id', 'type' => 'integer'),
76
		);
77
78
		// Get the donors list
79
		$data_ary = $this->ppde_entity_transactions->get_data($this->ppde_operator_transactions->build_sql_donorlist_data($get_donorlist_sql_ary), $additional_table_schema, $this->config['topics_per_page'], $start);
0 ignored issues
show
Bug introduced by
$this->config['topics_per_page'] of type string is incompatible with the type integer expected by parameter $limit of skouat\ppde\entity\main::get_data(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

79
		$data_ary = $this->ppde_entity_transactions->get_data($this->ppde_operator_transactions->build_sql_donorlist_data($get_donorlist_sql_ary), $additional_table_schema, /** @scrutinizer ignore-type */ $this->config['topics_per_page'], $start);
Loading history...
80
81
		// Get default currency data from the database
82
		$default_currency_data = $this->get_last_element($this->ppde_main_controller->get_default_currency_data($this->config['ppde_default_currency']));
0 ignored issues
show
Bug introduced by
The method get_default_currency_data() does not exist on skouat\ppde\controller\main_controller. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

82
		$default_currency_data = $this->get_last_element($this->ppde_main_controller->/** @scrutinizer ignore-call */ get_default_currency_data($this->config['ppde_default_currency']));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
84
		// Build pagination
85
		/** @type \phpbb\pagination $pagination */
86
		$pagination = $this->container->get('pagination');
87
		$pagination_url = append_sid($this->u_action);
88
		$total_donors = $this->ppde_operator_transactions->query_sql_count($get_donorlist_sql_ary, 'txn.user_id');
89
		$start = $pagination->validate_start($start, $this->config['topics_per_page'], $total_donors);
0 ignored issues
show
Bug introduced by
$this->config['topics_per_page'] of type string is incompatible with the type integer expected by parameter $per_page of phpbb\pagination::validate_start(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

89
		$start = $pagination->validate_start($start, /** @scrutinizer ignore-type */ $this->config['topics_per_page'], $total_donors);
Loading history...
90
		$pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_donors, $this->config['topics_per_page'], $start);
0 ignored issues
show
Bug introduced by
$this->config['topics_per_page'] of type string is incompatible with the type integer expected by parameter $per_page of phpbb\pagination::generate_template_pagination(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

90
		$pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_donors, /** @scrutinizer ignore-type */ $this->config['topics_per_page'], $start);
Loading history...
91
92
		foreach ($data_ary as $data)
93
		{
94
			$get_last_transaction_sql_ary = $this->ppde_operator_transactions->get_sql_donorlist_ary($data['max_txn_id']);
95
			$last_donation_data = $this->get_last_element($this->ppde_entity_transactions->get_data($this->ppde_operator_transactions->build_sql_donorlist_data($get_last_transaction_sql_ary)));
96
97
			$this->template->assign_block_vars('donorrow', array(
98
				'PPDE_DD_DONATED_AMOUNT' => $this->ppde_main_controller->currency_on_left(number_format($data['amount'], 2), $default_currency_data['currency_symbol'], (bool) $default_currency_data['currency_on_left']),
0 ignored issues
show
Bug introduced by
The method currency_on_left() does not exist on skouat\ppde\controller\main_controller. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
				'PPDE_DD_DONATED_AMOUNT' => $this->ppde_main_controller->/** @scrutinizer ignore-call */ currency_on_left(number_format($data['amount'], 2), $default_currency_data['currency_symbol'], (bool) $default_currency_data['currency_on_left']),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
99
				'PPDE_DD_LAST_DONATION'  => $this->ppde_main_controller->currency_on_left(number_format($last_donation_data['mc_gross'], 2), $default_currency_data['currency_symbol'], (bool) $default_currency_data['currency_on_left']),
100
				'PPDE_DD_USERNAME'       => get_username_string('full', $data['user_id'], $data['username'], $data['user_colour']),
101
			));
102
		}
103
	}
104
}
105