Plugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 15.55%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 57
ccs 7
cts 45
cp 0.1555
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A pluginDetails() 0 9 1
A boot() 0 4 1
A registerSettings() 0 12 1
A registerSchedule() 0 20 1
1
<?php namespace VojtaSvoboda\CnbRates;
2
3
use System\Classes\PluginBase;
4
use VojtaSvoboda\CnbRates\Models\Settings;
5
6
/**
7
 * CnbRates Plugin Information File
8
 */
9
class Plugin extends PluginBase
10
{
11
    /**
12
     * Returns information about this plugin.
13
     *
14
     * @return array
15
     */
16
    public function pluginDetails()
17
    {
18
        return [
19
            'name' => 'vojtasvoboda.cnbrates::lang.plugin.name',
20
            'description' => 'vojtasvoboda.cnbrates::lang.plugin.description',
21
            'author' => 'Vojta Svoboda',
22
            'icon' => 'icon-line-chart'
23
        ];
24
    }
25
26 1
    public function boot()
27 1
    {
28
        $this->app->bind('cnb', 'VojtaSvoboda\CnbRates\Facades\CnbFacade');
29
    }
30
31
    public function registerSettings()
32
    {
33
        return [
34
            'config' => [
35
                'label' => 'vojtasvoboda.cnbrates::lang.settings.label',
36
                'icon' => 'icon-line-chart',
37
                'description' => 'vojtasvoboda.cnbrates::lang.settings.description',
38
                'class' => 'VojtaSvoboda\CnbRates\Models\Settings',
39
                'order' => 500
40
            ]
41
        ];
42
    }
43
44 26
    public function registerSchedule($schedule)
45
    {
46
        // Exchange service daily update when allowed by Settings
47
        $schedule->call(function() {
48
            $cnb = $this->app->make('cnb');
49
            $cnb->updateTodayExchangeRates();
50
51
        })->daily()->when(function() {
52
            return !!Settings::get('exchange', true);
53 26
        });
54
55
        // PRIBOR service daily update when allowed by Settings
56
        $schedule->call(function() {
57
            $cnb = $this->app->make('cnb');
58
            $cnb->updateTodayPriborRates();
59
60 26
        })->daily()->when(function() {
61
            return !!Settings::get('pribor', true);
62 26
        });
63 26
    }
64
65
}