Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
tidy_cache
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_runnable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 should_run
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\cron\task\core;
15
16/**
17* Tidy cache cron task.
18*/
19class tidy_cache extends \phpbb\cron\task\base
20{
21    protected $config;
22    protected $cache;
23
24    /**
25    * Constructor.
26    *
27    * @param \phpbb\config\config $config The config
28    * @param \phpbb\cache\driver\driver_interface $cache The cache driver
29    */
30    public function __construct(\phpbb\config\config $config, \phpbb\cache\driver\driver_interface $cache)
31    {
32        $this->config = $config;
33        $this->cache = $cache;
34    }
35
36    /**
37    * Runs this cron task.
38    *
39    * @return void
40    */
41    public function run()
42    {
43        $this->cache->tidy();
44    }
45
46    /**
47    * Returns whether this cron task can run, given current board configuration.
48    *
49    * Tidy cache cron task runs if the cache implementation in use
50    * supports tidying.
51    *
52    * @return bool
53    */
54    public function is_runnable()
55    {
56        return true;
57    }
58
59    /**
60    * Returns whether this cron task should run now, because enough time
61    * has passed since it was last run.
62    *
63    * The interval between cache tidying is specified in board
64    * configuration.
65    *
66    * @return bool
67    */
68    public function should_run()
69    {
70        return $this->config['cache_last_gc'] < time() - $this->config['cache_gc'];
71    }
72}