Completed
Pull Request — master (#43)
by Jakub
09:30
created

click_controller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 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
	/** @var \phpbb\request\request */
25
	protected $request;
26
27
	/**
28
	 * Constructor
29
	 *
30
	 * @param \phpbb\ads\ad\manager    $manager Advertisement manager object
31
	 * @param \phpbb\controller\helper $helper  Controller helper object
32
	 * @param \phpbb\request\request   $request	Request object
33
	 */
34
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\controller\helper $helper, \phpbb\request\request $request)
35
	{
36
		$this->manager = $manager;
37
		$this->helper = $helper;
38
		$this->request = $request;
39
	}
40
41
	/**
42
	* Increment clicks for an ad
43
	*
44
	* @param	int	$ad_id	Advertisement ID
45
	* @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
0 ignored issues
show
Documentation introduced by
Should the return type not be \Symfony\Component\HttpFoundation\JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
46
	*/
47
	public function increment_clicks($ad_id)
48
	{
49
		if ($this->request->is_ajax() && !empty($ad_id))
50
		{
51
			$this->manager->increment_ad_clicks($ad_id);
52
53
			return new \Symfony\Component\HttpFoundation\JsonResponse();
54
		}
55
56
		throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED');
57
	}
58
}
59