Completed
Pull Request — master (#93)
by Janis
04:18
created

JobController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 70
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A process() 0 6 1
A getAllJobs() 0 5 1
A deleteJob() 0 6 1
1
<?php
2
3
/**
4
 * Nextcloud - OCR
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 * 
8
 * @author Janis Koehr <[email protected]>
9
 * @copyright Janis Koehr 2017
10
 */
11
namespace OCA\Ocr\Controller;
12
13
use OCA\Ocr\Service\JobService;
14
use OCP\AppFramework\Http\DataResponse;
15
use OCP\IRequest;
16
use OCP\AppFramework\Controller;
17
18
19
/**
20
 * Class JobController
21
 * 
22
 * @package OCA\Ocr\Controller
23
 */
24
class JobController extends Controller {
25
26
    /**
27
     *
28
     * @var string
29
     */
30
    private $userId;
31
32
    /**
33
     *
34
     * @var OcrService
35
     */
36
    private $service;
37
    use Errors;
38
39
    /**
40
     * JobController constructor.
41
     * 
42
     * @param string $AppName            
43
     * @param IRequest $request            
44
     * @param JobService $service            
45
     * @param
46
     *            $UserId
47
     */
48 7
    public function __construct($AppName, IRequest $request, JobService $service, $UserId) {
49 7
        parent::__construct($AppName, $request);
50 7
        $this->userId = $UserId;
51 7
        $this->service = $service;
0 ignored issues
show
Documentation Bug introduced by
It seems like $service of type object<OCA\Ocr\Service\JobService> is incompatible with the declared type object<OCA\Ocr\Controller\OcrService> of property $service.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
52 7
    }
53
54
    /**
55
     * Processing the srcFile(s)
56
     * @NoAdminRequired
57
     * 
58
     * @param string[] $languages
59
     *            - deu, eng...
60
     * @param array $files            
61
     * @return DataResponse
62
     */
63 2
    public function process($languages, $files) {
64 2
        return $this->handleNotFound(
65
                function () use ($languages, $files) {
66 2
                    return $this->service->process($languages, $files);
67 2
                });
68
    }
69
70
    /**
71
     * @NoAdminRequired
72
     * 
73
     * @return \OCP\AppFramework\Http\DataResponse
74
     */
75 2
    public function getAllJobs() {
76
        return $this->handleNotFound(function () {
77 2
            return $this->service->getAllJobsForUser($this->userId);
78 2
        });
79
    }
80
81
    /**
82
     * @NoAdminRequired
83
     * 
84
     * @param integer $id            
85
     * @return \OCP\AppFramework\Http\DataResponse
86
     */
87 2
    public function deleteJob($id) {
88 2
        return $this->handleNotFound(
89 2
                function () use ($id) {
90 2
                    return $this->service->deleteJob($id, $this->userId);
91 2
                });
92
    }
93
}