Code Duplication    Length = 38-40 lines in 2 locations

controller/click_controller.php 1 location

@@ 16-53 (lines=38) @@
13
/**
14
* Click controller
15
*/
16
class click_controller
17
{
18
	/** @var \phpbb\ads\ad\manager */
19
	protected $manager;
20
21
	/** @var \phpbb\request\request */
22
	protected $request;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param \phpbb\ads\ad\manager    $manager Advertisement manager object
28
	 * @param \phpbb\request\request   $request	Request object
29
	 */
30
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\request\request $request)
31
	{
32
		$this->manager = $manager;
33
		$this->request = $request;
34
	}
35
36
	/**
37
	* Increment clicks for an ad
38
	*
39
	* @param	int	$ad_id	Advertisement ID
40
	* @return	\Symfony\Component\HttpFoundation\JsonResponse	A Symfony JsonResponse object
41
	*/
42
	public function increment_clicks($ad_id)
43
	{
44
		if ($this->request->is_ajax() && !empty($ad_id))
45
		{
46
			$this->manager->increment_ad_clicks($ad_id);
47
48
			return new \Symfony\Component\HttpFoundation\JsonResponse();
49
		}
50
51
		throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED');
52
	}
53
}
54

controller/view_controller.php 1 location

@@ 16-55 (lines=40) @@
13
/**
14
 * View controller
15
 */
16
class view_controller
17
{
18
	/** @var \phpbb\ads\ad\manager */
19
	protected $manager;
20
21
	/** @var \phpbb\request\request */
22
	protected $request;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param \phpbb\ads\ad\manager    $manager Advertisement manager object
28
	 * @param \phpbb\request\request   $request	Request object
29
	 */
30
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\request\request $request)
31
	{
32
		$this->manager = $manager;
33
		$this->request = $request;
34
	}
35
36
	/**
37
	 * Increment views for ads
38
	 *
39
	 * @param	string	$ad_ids	Advertisement IDs
40
	 * @return	\Symfony\Component\HttpFoundation\JsonResponse	A Symfony JsonResponse object
41
	 */
42
	public function increment_views($ad_ids)
43
	{
44
		$ad_ids = explode('-', $ad_ids);
45
46
		if ($this->request->is_ajax())
47
		{
48
			$this->manager->increment_ads_views($ad_ids);
49
50
			return new \Symfony\Component\HttpFoundation\JsonResponse();
51
		}
52
53
		throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED');
54
	}
55
}
56