Passed
Branch master (7b1276)
by Marcel
06:24
created

DatasetService::getOwnDataset()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Data 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 2019 Marcel Scherello
10
 */
11
12
namespace OCA\Analytics\Service;
13
14
use OCA\Analytics\Activity\ActivityManager;
15
use OCA\Analytics\Controller\DbController;
16
use OCP\ILogger;
17
18
class DatasetService
19
{
20
    private $logger;
21
    private $DBController;
22
    private $ActivityManager;
23
24
    public function __construct(
25
        ILogger $logger,
26
        DbController $DBController,
27
        ActivityManager $ActivityManager
28
    )
29
    {
30
        $this->logger = $logger;
31
        $this->DBController = $DBController;
32
        $this->ActivityManager = $ActivityManager;
33
    }
34
35
    /**
36
     * Get content of linked CSV file
37
     */
38
    public function index()
39
    {
40
        return $this->DBController->getDatasets();
41
    }
42
43
    /**
44
     * read own dataset
45
     * @param $id
46
     * @return array
47
     */
48
    public function getOwnDataset($id)
49
    {
50
        return $this->DBController->getOwnDataset($id);
51
    }
52
53
    /**
54
     * create new dataset
55
     * @return array
56
     */
57
    public function create()
58
    {
59
        $this->ActivityManager->triggerEvent(0, ActivityManager::OBJECT_DATASET, ActivityManager::SUBJECT_DATASET_ADD);
60
        return $this->DBController->createDataset();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->DBController->createDataset() returns the type true which is incompatible with the documented return type array.
Loading history...
61
    }
62
63
    /**
64
     * Get content of linked CSV file
65
     * @param $id
66
     * @return array
67
     */
68
    public function delete($id)
69
    {
70
        $this->ActivityManager->triggerEvent($id, ActivityManager::OBJECT_DATASET, ActivityManager::SUBJECT_DATASET_DELETE);
71
        return $this->DBController->deleteDataset($id);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->DBController->deleteDataset($id) returns the type true which is incompatible with the documented return type array.
Loading history...
72
    }
73
74
    /**
75
     * Get content of linked CSV file
76
     * @param int $datasetId
77
     * @param $name
78
     * @param $parent
79
     * @param $type
80
     * @param $link
81
     * @param $visualization
82
     * @param $chart
83
     * @param $dimension1
84
     * @param $dimension2
85
     * @param $dimension3
86
     * @return array
87
     */
88
    public function update(int $datasetId, $name, $parent, $type, $link, $visualization, $chart, $dimension1, $dimension2, $dimension3)
89
    {
90
        return $this->DBController->updateDataset($datasetId, $name, $parent, $type, $link, $visualization, $chart, $dimension1, $dimension2, $dimension3);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->DBControll...imension2, $dimension3) returns the type true which is incompatible with the documented return type array.
Loading history...
91
    }
92
}