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

OcrJob::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
ccs 11
cts 11
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 11
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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\Db;
12
13
use OCP\AppFramework\Db\Entity;
14
use JsonSerializable;
15
16
17
/**
18
 * Class to represent a ocr job.
19
 * 
20
 * @method string getStatus()
21
 * @method void setStatus(string $status)
22
 * @method string getSource()
23
 * @method void setSource(integer $source)
24
 * @method string getTarget()
25
 * @method void setTarget(string $target)
26
 * @method string getTempFile()
27
 * @method void setTempFile(string $tempFile)
28
 * @method string getType()
29
 * @method void setType(string $type)
30
 * @method string getUserId()
31
 * @method void setUserId(string $userId)
32
 * @method boolean getErrorDisplayed()
33
 * @method void setErrorDisplayed(boolean $errorDisplayed)
34
 * @method void setOriginalFilename(string $originalFilename)
35
 * @method string getOriginalFilename()
36
 * @method void setErrorLog(string $errorLog)
37
 * @method string getErrorLog()
38
 */
39
class OcrJob extends Entity implements JsonSerializable {
40
41
    /**
42
     *
43
     * @var string
44
     */
45
    protected $status;
46
47
    /**
48
     *
49
     * @var string
50
     */
51
    protected $source;
52
53
    /**
54
     *
55
     * @var string
56
     */
57
    protected $target;
58
59
    /**
60
     *
61
     * @var string
62
     */
63
    protected $tempFile;
64
65
    /**
66
     *
67
     * @var string
68
     */
69
    protected $type;
70
71
    /**
72
     *
73
     * @var string
74
     */
75
    protected $userId;
76
77
    /**
78
     *
79
     * @var boolean
80
     */
81
    protected $errorDisplayed;
82
83
    /**
84
     *
85
     * @var string
86
     */
87
    protected $originalFilename;
88
89
    /**
90
     *
91
     * @var string
92
     */
93
    protected $errorLog;
94
95
    /**
96
     * OcrJob constructor.
97
     * 
98
     * @param string $status            
99
     * @param string $source            
100
     * @param string $target            
101
     * @param string $tempFile            
102
     * @param string $type            
103
     * @param string $userId            
104
     * @param boolean $errorDisplayed            
105
     * @param string $originalFilename            
106
     * @param string $errorLog            
107
     */
108 20
    public function __construct($status = null, $source = null, $target = null, $tempFile = null, $type = null, $userId = null, 
109
            $errorDisplayed = null, $originalFilename = null, $errorLog = null) {
110 20
        $this->setStatus($status);
111 20
        $this->setSource($source);
112 20
        $this->setTarget($target);
113 20
        $this->setTempFile($tempFile);
114 20
        $this->setType($type);
115 20
        $this->setUserId($userId);
116 20
        $this->setErrorDisplayed($errorDisplayed);
117 20
        $this->setOriginalFilename($originalFilename);
118 20
        $this->setErrorLog($errorLog);
119 20
    }
120
121
    /**
122
     * Specify data which should be serialized to JSON
123
     * 
124
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
125
     * @return mixed data which can be serialized by <b>json_encode</b>,
126
     *         which is a value of any type other than a resource.
127
     * @since 5.4.0
128
     */
129 2
    function jsonSerialize() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
130
        return [
131 2
                'id' => $this->id,
132 2
                'status' => $this->status,
133 2
                'source' => $this->source,
134 2
                'target' => $this->target,
135 2
                'tempFile' => $this->tempFile,
136 2
                'type' => $this->type,
137 2
                'userId' => $this->userId,
138 2
                'errorDisplayed' => $this->errorDisplayed,
139 2
                'originalFilename' => $this->originalFilename,
140 2
                'errorLog' => $this->errorLog
141
        ];
142
    }
143
}