-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcron.php
38 lines (30 loc) · 1.07 KB
/
cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use KirchenImWeb\Helpers\Configuration;
use KirchenImWeb\Helpers\Database;
use KirchenImWeb\Helpers\Exporter;
use KirchenImWeb\Updaters\LinkChecker;
use KirchenImWeb\Updaters\SocialMediaUpdater;
require __DIR__ . '/src/autoload.php';
$time = microtime(true);
$socialMediaNetworks = array_keys(Configuration::getWebsiteTypesToCompare());
$argumentNamesForSocialMedia = array_map(static fn($i) => $i . ':', $socialMediaNetworks);
$args = getopt('', array_merge(['links:'], $argumentNamesForSocialMedia));
$database = new Database();
Exporter::run($database);
if (isset($args['links'])) {
$count = (int)$args['links'];
if ($count > 0) {
LinkChecker::run($database, $count);
}
}
$socialMediaUpdater = new SocialMediaUpdater($database);
foreach ($socialMediaNetworks as $network) {
if (isset($args[$network])) {
$count = (int)$args[$network];
if ($count > 0) {
$socialMediaUpdater->updateNetwork($network, $count);
}
}
}
$duration = (microtime(true) - $time);
echo sprintf('Executed in %.2f seconds.', $duration) . PHP_EOL;