Passed
Push — master ( 0b1a33...6372a5 )
by Marcel
06:49
created

DatasetController::updateOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 2021 Marcel Scherello
10
 */
11
12
namespace OCA\Analytics\Controller;
13
14
use OCA\Analytics\Service\DatasetService;
15
use OCP\AppFramework\Controller;
16
use OCP\AppFramework\Http\DataResponse;
17
use OCP\IRequest;
18
use Psr\Log\LoggerInterface;
19
20
class DatasetController extends Controller
21
{
22
    private $logger;
23
    private $DatasetService;
24
25
    public function __construct(
26
        $appName,
27
        IRequest $request,
28
        LoggerInterface $logger,
29
        DatasetService $DatasetService
30
    )
31
    {
32
        parent::__construct($appName, $request);
33
        $this->logger = $logger;
34
        $this->DatasetService = $DatasetService;
35
    }
36
37
    /**
38
     * get all datasets
39
     *
40
     * @NoAdminRequired
41
     * @return DataResponse
42
     */
43
    public function index()
44
    {
45
        return $this->DatasetService->index();
46
    }
47
48
    /**
49
     * create new dataset
50
     *
51
     * @NoAdminRequired
52
     * @param string $file
53
     * @return int
54
     */
55
    public function create($file = '')
56
    {
57
        return $this->DatasetService->create($file);
0 ignored issues
show
Bug introduced by
The call to OCA\Analytics\Service\DatasetService::create() has too few arguments starting with dimension1. ( Ignorable by Annotation )

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

57
        return $this->DatasetService->/** @scrutinizer ignore-call */ create($file);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
58
    }
59
60
    /**
61
     * get own dataset details
62
     *
63
     * @NoAdminRequired
64
     * @param int $datasetId
65
     * @return array
66
     */
67
    public function read(int $datasetId)
68
    {
69
        return $this->DatasetService->read($datasetId);
70
    }
71
72
    /**
73
     * Delete Dataset and all depending objects
74
     *
75
     * @NoAdminRequired
76
     * @param int $datasetId
77
     * @return bool
78
     */
79
    public function delete(int $datasetId)
80
    {
81
        return $this->DatasetService->delete($datasetId);
82
    }
83
84
    /**
85
     * get dataset details
86
     *
87
     * @NoAdminRequired
88
     * @param int $datasetId
89
     * @param $name
90
     * @param null $dimension1
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $dimension1 is correct as it would always require null to be passed?
Loading history...
91
     * @param null $dimension2
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $dimension2 is correct as it would always require null to be passed?
Loading history...
92
     * @param null $value
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $value is correct as it would always require null to be passed?
Loading history...
93
     * @return bool
94
     * @throws \OCP\DB\Exception
95
     */
96
    public function update(int $datasetId, $name, $dimension1 = null, $dimension2 = null, $value = null)
97
    {
98
        return $this->DatasetService->update($datasetId, $name, $dimension1, $dimension2, $value);
99
    }
100
101
}