metarefresh_hook_cron()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 16
rs 9.9332
1
<?php
2
3
declare(strict_types=1);
4
5
use SimpleSAML\Configuration;
6
use SimpleSAML\Logger;
7
use Webmozart\Assert\Assert;
8
9
/**
10
 * Hook to run a cron job.
11
 *
12
 * @param array &$croninfo  Output
13
 */
14
function metarefresh_hook_cron(array &$croninfo): void
15
{
16
    Assert::keyExists($croninfo, 'summary');
17
    Assert::keyExists($croninfo, 'tag');
18
19
    Logger::info('cron [metarefresh]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
20
21
    $config = Configuration::getInstance();
22
    $mconfig = Configuration::getOptionalConfig('module_metarefresh.php');
23
24
    $mf = new \SimpleSAML\Module\metarefresh\MetaRefresh($config, $mconfig);
25
26
    try {
27
        $mf->runRefresh($croninfo['tag']);
28
    } catch (\Exception $e) {
29
        $croninfo['summary'][] = 'Error during metarefresh: ' . $e->getMessage();
30
    }
31
}
32