Passed
Push — master ( 9e3476...4ce6d3 )
by Marcel
03:32
created

Operation::onEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Data Analytics
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the LICENSE.md file.
8
 *
9
 * @author Marcel Scherello <[email protected]>
10
 * @copyright 2019 Marcel Scherello
11
 */
12
13
namespace OCA\Analytics\Flow;
14
15
use OCP\EventDispatcher\Event;
16
use OCP\EventDispatcher\IEventDispatcher;
17
use OCP\ILogger;
18
use OCP\Util;
19
use OCP\WorkflowEngine\EntityContext\IDisplayText;
0 ignored issues
show
Bug introduced by
The type OCP\WorkflowEngine\EntityContext\IDisplayText 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\WorkflowEngine\EntityContext\IUrl;
0 ignored issues
show
Bug introduced by
The type OCP\WorkflowEngine\EntityContext\IUrl 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\WorkflowEngine\IEntity;
0 ignored issues
show
Bug introduced by
The type OCP\WorkflowEngine\IEntity 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...
22
use OCP\WorkflowEngine\IManager as FlowManager;
23
use OCP\WorkflowEngine\IOperation;
24
use OCP\WorkflowEngine\IRuleMatcher;
0 ignored issues
show
Bug introduced by
The type OCP\WorkflowEngine\IRuleMatcher 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...
25
use Symfony\Component\EventDispatcher\GenericEvent;
26
use UnexpectedValueException;
27
28
class Operation implements IOperation
29
{
30
31
    private $logger;
32
33
    public function __construct(
34
        ILogger $logger
35
    )
36
    {
37
        $this->logger = $logger;
38
    }
39
40
    public static function register(IEventDispatcher $dispatcher): void
41
    {
42
        $dispatcher->addListener(FlowManager::EVENT_NAME_REG_OPERATION, function (GenericEvent $event) {
0 ignored issues
show
Bug introduced by
The constant OCP\WorkflowEngine\IMana...VENT_NAME_REG_OPERATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
43
            $operation = \OC::$server->query(Operation::class);
44
            $event->getSubject()->registerOperation($operation);
45
            Util::addScript('analytics', 'flow');
46
        });
47
    }
48
49
    public function getDisplayName(): string
50
    {
51
        return $this->l->t('Write to Analytics');
0 ignored issues
show
Bug Best Practice introduced by
The property l does not exist on OCA\Analytics\Flow\Operation. Did you maybe forget to declare it?
Loading history...
52
    }
53
54
    public function getDescription(): string
55
    {
56
        return $this->l->t('Writes data to report');
0 ignored issues
show
Bug Best Practice introduced by
The property l does not exist on OCA\Analytics\Flow\Operation. Did you maybe forget to declare it?
Loading history...
57
    }
58
59
    public function getIcon(): string
60
    {
61
        return $this->urlGenerator->imagePath('analytics', 'app.svg');
0 ignored issues
show
Bug Best Practice introduced by
The property urlGenerator does not exist on OCA\Analytics\Flow\Operation. Did you maybe forget to declare it?
Loading history...
62
    }
63
64
    public function isAvailableForScope(int $scope): bool
0 ignored issues
show
Unused Code introduced by
The parameter $scope is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function isAvailableForScope(/** @scrutinizer ignore-unused */ int $scope): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
        return true;
67
    }
68
69
    /**
70
     * Validates whether a configured workflow rule is valid. If it is not,
71
     * an `\UnexpectedValueException` is supposed to be thrown.
72
     *
73
     * @throws UnexpectedValueException
74
     * @since 9.1
75
     */
76
    public function validateOperation($name, array $checks, $operation): void
77
    {
78
    }
79
80
    public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function onEvent(string $eventName, /** @scrutinizer ignore-unused */ Event $event, IRuleMatcher $ruleMatcher): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $ruleMatcher is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function onEvent(string $eventName, Event $event, /** @scrutinizer ignore-unused */ IRuleMatcher $ruleMatcher): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $eventName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

80
    public function onEvent(/** @scrutinizer ignore-unused */ string $eventName, Event $event, IRuleMatcher $ruleMatcher): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
81
    {
82
        $this->logger->debug("Test Flow Operation");
83
    }
84
}