viglink::should_run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * VigLink extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2016 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\viglink\cron;
12
13
/**
14
 * Viglink cron task.
15
 */
16
class viglink extends \phpbb\cron\task\base
17
{
18
	/** @var \phpbb\config\config $config Config object */
19
	protected $config;
20
21
	/** @var \phpbb\viglink\acp\viglink_helper $helper Viglink helper object */
22
	protected $helper;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param \phpbb\config\config              $config         Config object
28
	 * @param \phpbb\viglink\acp\viglink_helper $viglink_helper Viglink helper object
29
	 * @access public
30
	 */
31
	public function __construct(\phpbb\config\config $config, \phpbb\viglink\acp\viglink_helper $viglink_helper)
32
	{
33
		$this->config = $config;
34
		$this->helper = $viglink_helper;
35
	}
36
37
	/**
38
	 * {@inheritDoc}
39
	 */
40
	public function run()
41
	{
42
		try
43
		{
44
			$this->helper->set_viglink_services(true);
45
		}
46
		catch (\RuntimeException $e)
47
		{
48
			$this->helper->log_viglink_error($e->getMessage());
49
		}
50
	}
51
52
	/**
53
	 * {@inheritDoc}
54
	 */
55
	public function is_runnable()
56
	{
57
		return (bool) $this->config['viglink_enabled'];
58
	}
59
60
	/**
61
	 * {@inheritDoc}
62
	 */
63
	public function should_run()
64
	{
65
		return $this->config['viglink_last_gc'] < strtotime('24 hours ago');
66
	}
67
}
68