Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
prune_notifications
0.00% covered (danger)
0.00%
0 / 6
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 / 2
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* Prune notifications cron task.
18*/
19class prune_notifications extends \phpbb\cron\task\base
20{
21    protected $config;
22    protected $notification_manager;
23
24    /**
25    * Constructor.
26    *
27    * @param \phpbb\config\config $config The config
28    * @param \phpbb\notification\manager $notification_manager Notification manager
29    */
30    public function __construct(\phpbb\config\config $config, \phpbb\notification\manager $notification_manager)
31    {
32        $this->config = $config;
33        $this->notification_manager = $notification_manager;
34    }
35
36    /**
37    * {@inheritdoc}
38    */
39    public function run()
40    {
41        // time minus expire days in seconds
42        $timestamp = time() - ($this->config['read_notification_expire_days'] * 60 * 60 * 24);
43        $this->notification_manager->prune_notifications($timestamp);
44    }
45
46    /**
47    * {@inheritdoc}
48    */
49    public function is_runnable()
50    {
51        return (bool) $this->config['read_notification_expire_days'];
52    }
53
54    /**
55    * {@inheritdoc}
56    */
57    public function should_run()
58    {
59        return $this->config['read_notification_last_gc'] < time() - $this->config['read_notification_gc'];
60    }
61}