Passed
Push — master ( fc42a6...b0746a )
by Marcel
02:44 queued 11s
created

UserService::deleteUserData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 1
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\Service;
13
14
use Psr\Log\LoggerInterface;
15
16
class UserService
17
{
18
    private $logger;
19
20
    public function __construct(
21
        LoggerInterface $logger,
22
        ReportService $reportService,
23
        DatasetService $datasetService
24
    )
25
    {
26
        $this->logger = $logger;
27
        $this->ReportService = $reportService;
0 ignored issues
show
Bug Best Practice introduced by
The property ReportService does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28
        $this->DatasetService = $datasetService;
0 ignored issues
show
Bug Best Practice introduced by
The property DatasetService does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
    }
30
31
    /**
32
     * delete all user data
33
     *
34
     * @param $userId
35
     * @return bool
36
     * @throws \OCP\DB\Exception
37
     */
38
    public function deleteUserData($userId)
39
    {
40
        $this->logger->info('Deleting all Analytics data for: ' . $userId);
41
        $this->ReportService->deleteByUser($userId);
42
        $this->DatasetService->deleteByUser($userId);
43
        return true;
44
    }
45
}