Passed
Push — master ( a94fd2...d508fa )
by Stanislav
03:13 queued 15s
created

cron_cleaner::should_run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
*
5
* @package phpBB Gallery Core
6
* @copyright (c) 2022 DreadDendy
7
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
*
9
*/
10
11
namespace phpbbgallery\core\cron;
12
13
/**
14
 * phpbbgallery cron task.
15
 */
16
class cron_cleaner extends \phpbb\cron\task\base
0 ignored issues
show
Bug introduced by
The type phpbb\cron\task\base 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...
17
{
18
	/** @var \phpbbgallery\core\config  */
19
	protected $gallery_config;
20
21
	/** @var \phpbbgallery\core\upload  */
22
	protected $gallery_upload;
23
24
	/**
25
	 * Constructor
26
	 *
27
	 * @param \phpbbgallery\core\config $gallery_config
28
	 * @param \phpbbgallery\core\upload $gallery_upload
29
	 * @access public
30
	 */
31
	public function __construct(\phpbbgallery\core\config $gallery_config, \phpbbgallery\core\upload $gallery_upload)
32
	{
33
		$this->gallery_config = $gallery_config;
34
		$this->gallery_upload = $gallery_upload;
35
	}
36
37
	/**
38
	 * {@inheritDoc}
39
	 */
40
	public function run()
41
	{
42
		$this->gallery_upload->prune_orphan();
43
		$this->gallery_config->set('prune_orphan_time', time());
44
	}
45
46
	/**
47
	 * {@inheritDoc}
48
	 */
49
	public function should_run()
50
	{
51
		return $this->gallery_config->get('prune_orphan_time') < strtotime('24 hours ago');
52
	}
53
54
	/**
55
	 * {@inheritDoc}
56
	 */
57
	public function is_runnable()
58
	{
59
		return true;
60
	}
61
}
62