cron_cleaner   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 44
ccs 0
cts 17
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A is_runnable() 0 3 1
A run() 0 4 1
A should_run() 0 3 1
1
<?php
2
/**
3
 * phpBB Gallery - Core Extension
4
 *
5
 * @package   phpbbgallery/core
6
 * @author    nickvergessen
7
 * @author    satanasov
8
 * @author    Leinad4Mind
9
 * @author    DreadDendy
10
 * @copyright 2018- Leinad4Mind, 2022 DreadDendy
11
 * @license   GPL-2.0-only
12
 */
13
14
namespace phpbbgallery\core\cron;
15
16
/**
17
 * phpbbgallery cron task.
18
 */
19
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...
20
{
21
	/** @var \phpbbgallery\core\config  */
22
	protected $gallery_config;
23
24
	/** @var \phpbbgallery\core\upload  */
25
	protected $gallery_upload;
26
27
	/**
28
	 * Constructor
29
	 *
30
	 * @param \phpbbgallery\core\config $gallery_config
31
	 * @param \phpbbgallery\core\upload $gallery_upload
32
	 * @access public
33
	 */
34
	public function __construct(\phpbbgallery\core\config $gallery_config, \phpbbgallery\core\upload $gallery_upload)
35
	{
36
		$this->gallery_config = $gallery_config;
37
		$this->gallery_upload = $gallery_upload;
38
	}
39
40
	/**
41
	 * {@inheritDoc}
42
	 */
43
	public function run()
44
	{
45
		$this->gallery_upload->prune_orphan();
46
		$this->gallery_config->set('prune_orphan_time', time());
47
	}
48
49
	/**
50
	 * {@inheritDoc}
51
	 */
52
	public function should_run()
53
	{
54
		return $this->gallery_config->get('prune_orphan_time') < strtotime('24 hours ago');
55
	}
56
57
	/**
58
	 * {@inheritDoc}
59
	 */
60
	public function is_runnable()
61
	{
62
		return true;
63
	}
64
}
65