Passed
Push — master ( 47c528...f299b2 )
by Marcel
05:27 queued 16s
created

ContentProvider::getAppId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Analytics
4
 *
5
 * SPDX-FileCopyrightText: 2024 Marcel Scherello
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8
9
namespace OCA\Analytics\ContextChat;
10
11
use OCA\ContextChat\Public\IContentProvider;
0 ignored issues
show
Bug introduced by
The type OCA\ContextChat\Public\IContentProvider 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...
12
use OCP\IURLGenerator;
0 ignored issues
show
Bug introduced by
The type OCP\IURLGenerator 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...
13
use OCA\ContextChat\Event\ContentProviderRegisterEvent;
0 ignored issues
show
Bug introduced by
The type OCA\ContextChat\Event\ContentProviderRegisterEvent 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...
14
use OCP\EventDispatcher\Event;
0 ignored issues
show
Bug introduced by
The type OCP\EventDispatcher\Event 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...
15
use Psr\Log\LoggerInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Log\LoggerInterface 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...
16
17
/**
18
 * This interface defines methods to implement a content provider
19
 * @since 1.1.0
20
 */
21
class ContentProvider implements IContentProvider {
22
	private $logger;
23
24
	public function __construct(
25
		private IURLGenerator $urlGenerator,
26
		LoggerInterface       $logger,
27
	) {
28
		$this->logger = $logger;
29
	}
30
31
	public function handle(Event $event): void {
32
		if (!$event instanceof ContentProviderRegisterEvent) {
33
			return;
34
		}
35
		$event->registerContentProvider('analytics', 'report', ContentProvider::class);
36
	}
37
38
	/**
39
	 * The ID of the provider
40
	 *
41
	 * @return string
42
	 * @since 1.1.0
43
	 */
44
	public function getId(): string {
45
		return 'report';
46
	}
47
48
	/**
49
	 * The ID of the app making the provider avaialble
50
	 *
51
	 * @return string
52
	 * @since 1.1.0
53
	 */
54
	public function getAppId(): string {
55
		return 'analytics';
56
	}
57
58
	/**
59
	 * The absolute URL to the content item
60
	 *
61
	 * @param string $id
62
	 * @return string
63
	 * @since 1.1.0
64
	 */
65
	public function getItemUrl(string $id): string {
66
		return $this->urlGenerator->linkToRouteAbsolute('analytics.page.index') . '#/r/' . $id;
67
	}
68
69
	/**
70
	 * Starts the initial import of content items into content chat
71
	 *
72
	 * @return void
73
	 * @since 1.1.0
74
	 */
75
	public function triggerInitialImport(): void {
76
		return;
77
	}
78
}