Completed
Pull Request — master (#43)
by Jakub
08:12
created

click_controller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 38
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A increment_clicks() 0 11 2
1
<?php
2
/**
3
 *
4
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ads\controller;
12
13
/**
14
* Front controller
15
*/
16
class click_controller
17
{
18
	/** @var \phpbb\ads\ad\manager */
19
	protected $manager;
20
21
	/** @var \phpbb\controller\helper */
22
	protected $helper;
23
24
	/**
25
	* Constructor
26
	*
27
	* @param \phpbb\ads\ad\manager		$manager	Advertisement manager object
28
	* @param \phpbb\controller\helper	$helper		Controller helper object
29
	*/
30
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\controller\helper $helper)
31
	{
32
		$this->manager = $manager;
33
		$this->helper = $helper;
34
	}
35
36
	/**
37
	* Increment clicks for an ad
38
	*
39
	* @param	int	$ad_id	Advertisement ID
40
	* @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
41
	*/
42
	public function increment_clicks($ad_id)
43
	{
44
		if (!$ad_id)
45
		{
46
			throw new \phpbb\exception\http_exception(404, 'NOT_FOUND');
47
		}
48
49
		$this->manager->increment_ad_clicks($ad_id);
0 ignored issues
show
Documentation introduced by
$ad_id is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
51
		return $this->helper->message('');
52
	}
53
}
54