Passed
Push — master ( 9e7c9c...370ffa )
by Marcel
02:24
created

Application20   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 5 1
A registerNavigationEntry() 0 12 1
A registerNotifications() 0 4 1
A __construct() 0 3 1
A boot() 0 11 2
1
<?php
2
/**
3
 * Analytics
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the LICENSE.md file.
7
 *
8
 * @author Marcel Scherello <[email protected]>
9
 * @copyright 2020 Marcel Scherello
10
 */
11
12
namespace OCA\Analytics\AppInfo;
13
14
use OCA\Analytics\Dashboard\Widget;
15
use OCA\Analytics\Flow\Operation;
16
use OCA\Analytics\Notification\Notifier;
17
use OCP\AppFramework\App;
18
use OCP\AppFramework\Bootstrap\IBootContext;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IBootContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use OCP\AppFramework\Bootstrap\IBootstrap;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IBootstrap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use OCP\AppFramework\Bootstrap\IRegistrationContext;
0 ignored issues
show
Bug introduced by
The type OCP\AppFramework\Bootstrap\IRegistrationContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use OCP\AppFramework\QueryException;
22
use OCP\EventDispatcher\IEventDispatcher;
23
use OCP\IServerContainer;
24
25
class Application20 extends App implements IBootstrap
26
{
27
    public const APP_ID = 'analytics';
28
29
    /** @var IServerContainer */
30
    private $server;
31
32
    public function __construct(array $urlParams = [])
33
    {
34
        parent::__construct(self::APP_ID, $urlParams);
35
    }
36
37
    public function register(IRegistrationContext $context): void
38
    {
39
        $context->registerDashboardWidget(Widget::class);
40
        $this->registerNavigationEntry();
41
        $this->registerNotifications();
42
    }
43
44
    protected function registerNavigationEntry(): void
45
    {
46
        $navigationEntry = function () {
47
            return [
48
                'id' => 'analytics',
49
                'order' => 6,
50
                'name' => \OC::$server->getL10N('analytics')->t('Analytics'),
51
                'href' => \OC::$server->getURLGenerator()->linkToRoute('analytics.page.index'),
52
                'icon' => \OC::$server->getURLGenerator()->imagePath('analytics', 'app.svg'),
53
            ];
54
        };
55
        \OC::$server->getNavigationManager()->add($navigationEntry);
56
    }
57
58
    public function registerNotifications(): void
59
    {
60
        $notificationManager = \OC::$server->getNotificationManager();
61
        $notificationManager->registerNotifierService(Notifier::class);
62
    }
63
64
    public function boot(IBootContext $context): void
65
    {
66
67
        $server = $this->getContainer()->getServer();
68
        /** @var IEventDispatcher $dispatcher */
69
        try {
70
            $dispatcher = $server->query(IEventDispatcher::class);
71
        } catch (QueryException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
72
        }
73
74
        Operation::register($dispatcher);
75
    }
76
77
}