Passed
Pull Request — master (#2)
by Sergey
04:32
created

RunModel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
cc 1
nc 1
nop 6
crap 1
1
<?php
2
3
/**
4
 * Created by PhpStorm.
5
 * Project: json-rpc-server
6
 * User: sv
7
 * Date: 06.01.2021
8
 * Time: 19:17
9
 */
10
11
declare(strict_types=1);
12
13
namespace Onnov\JsonRpcServer\Model;
14
15
use Onnov\JsonRpcServer\ApiFactoryInterface;
16
17
/**
18
 * Class RunModel
19
 * @package Onnov\JsonRpcServer\Model
20
 */
21
class RunModel
22
{
23
    /** @var ApiFactoryInterface */
24
    private $apiFactory;
25
26
    /** @var string */
27
    private $json;
28
29
    /** @var bool */
30
    private $resultAuth;
31
32
    /** @var string[] */
33
    private $methodsWithoutAuth;
34
35
    /**
36
     * custom errors for methods
37
     *
38
     * @var array<int, string>
39
     */
40
    private $errors;
41
42
    /** @var bool */
43
    private $responseCheck;
44
45
    /**
46
     * RunModel constructor.
47
     * @param ApiFactoryInterface $apiFactory
48
     * @param string $json
49
     * @param bool $resultAuth
50
     * @param string[] $methodsWithoutAuth
51
     * @param array<int, string> $errors
52
     * @param bool $responseCheck
53
     */
54 6
    public function __construct(
55
        ApiFactoryInterface $apiFactory,
56
        string $json,
57
        bool $resultAuth = true,
58
        array $methodsWithoutAuth = [],
59
        array $errors = [],
60
        bool $responseCheck = false
61
    ) {
62
        $this
63 6
            ->setApiFactory($apiFactory)
64 6
            ->setJson($json)
65 6
            ->setResultAuth($resultAuth)
66 6
            ->setMethodsWithoutAuth($methodsWithoutAuth)
67 6
            ->setErrors($errors)
68 6
            ->setResponseCheck($responseCheck);
69 6
    }
70
71
    /**
72
     * @return ApiFactoryInterface
73
     */
74 3
    public function getApiFactory(): ApiFactoryInterface
75
    {
76 3
        return $this->apiFactory;
77
    }
78
79
    /**
80
     * @param ApiFactoryInterface $apiFactory
81
     * @return RunModel
82
     */
83 6
    public function setApiFactory(ApiFactoryInterface $apiFactory): self
84
    {
85 6
        $this->apiFactory = $apiFactory;
86
87 6
        return $this;
88
    }
89
90
    /**
91
     * @return string
92
     */
93 6
    public function getJson(): string
94
    {
95 6
        return $this->json;
96
    }
97
98
    /**
99
     * @param string $json
100
     * @return RunModel
101
     */
102 6
    public function setJson(string $json): self
103
    {
104 6
        $this->json = $json;
105
106 6
        return $this;
107
    }
108
109
    /**
110
     * @return bool
111
     */
112 4
    public function isResultAuth(): bool
113
    {
114 4
        return $this->resultAuth;
115
    }
116
117
    /**
118
     * @param bool $resultAuth
119
     * @return RunModel
120
     */
121 6
    public function setResultAuth(bool $resultAuth): self
122
    {
123 6
        $this->resultAuth = $resultAuth;
124
125 6
        return $this;
126
    }
127
128
    /**
129
     * @return string[]
130
     */
131 4
    public function getMethodsWithoutAuth(): array
132
    {
133 4
        return $this->methodsWithoutAuth;
134
    }
135
136
    /**
137
     * @param string[] $methodsWithoutAuth
138
     * @return RunModel
139
     */
140 6
    public function setMethodsWithoutAuth(array $methodsWithoutAuth): self
141
    {
142 6
        $this->methodsWithoutAuth = $methodsWithoutAuth;
143
144 6
        return $this;
145
    }
146
147
    /**
148
     * @return array<int, string>
149
     */
150
    public function getErrors(): array
151
    {
152
        return $this->errors;
153
    }
154
155
    /**
156
     * @param array<int, string> $errors
157
     * @return RunModel
158
     */
159 6
    public function setErrors(array $errors): self
160
    {
161 6
        $this->errors = $errors;
162
163 6
        return $this;
164
    }
165
166
    /**
167
     * @return bool
168
     */
169 2
    public function isResponseCheck(): bool
170
    {
171 2
        return $this->responseCheck;
172
    }
173
174
    /**
175
     * @param bool $responseCheck
176
     * @return RunModel
177
     */
178 6
    public function setResponseCheck(bool $responseCheck): self
179
    {
180 6
        $this->responseCheck = $responseCheck;
181
182 6
        return $this;
183
    }
184
}
185