AutoReloadComponent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A after() 0 11 4
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace App\Controller\Component;
14
15
use Cake\Controller\Component;
16
use Saito\User\CurrentUser\CurrentUserInterface;
17
18
/**
19
 * Class AutoRefreshComponent
20
 *
21
 * @package App\Controller\Component
22
 */
23
class AutoReloadComponent extends Component
24
{
25
    /**
26
     * Set auto refresh time
27
     *
28
     * @param CurrentUserInterface $CurrentUser period in minutes
29
     * @return void
30
     */
31
    public function after(CurrentUserInterface $CurrentUser)
32
    {
33
        if (!$CurrentUser->isLoggedIn()) {
34
            return;
35
        }
36
        $period = $CurrentUser->get('user_forum_refresh_time');
37
        if (!is_numeric($period) || $period <= 0) {
38
            return;
39
        }
40
        $period = $period * 60;
41
        $this->getController()->set('autoPageReload', $period);
42
    }
43
}
44