Passed
Pull Request — master (#545)
by Dmitriy
07:22
created

ApiResponseData::getErrorMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Dto;
6
7
use OpenApi\Annotations as OA;
0 ignored issues
show
Bug introduced by
The type OpenApi\Annotations was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * @OA\Schema(
11
 *      schema="Response",
12
 * )
13
 * @OA\Schema(
14
 *      schema="BadResponse",
15
 *      allOf={
16
 *          @OA\Schema(ref="#/components/schemas/Response"),
17
 *          @OA\Schema(
18
 *              @OA\Property(
19
 *                  property="status",
20
 *                  example="failed",
21
 *              ),
22
 *              @OA\Property(property="error_message", example="Error description message"),
23
 *              @OA\Property(property="error_code", nullable=true, example=400),
24
 *              @OA\Property(
25
 *                  property="data",
26
 *                  example=null
27
 *              ),
28
 *          )
29
 *      }
30
 * )
31
 */
32
final class ApiResponseData
33
{
34
    /**
35
     * @OA\Property(
36
     *      property="status",
37
     *      format="string",
38
     *      example="success",
39
     *      enum={"success", "failed"}
40
     * )
41
     */
42
    private string $status = '';
43
44
    /**
45
     * @OA\Property(
46
     *     property="error_message",
47
     *     format="string",
48
     *     example=""
49
     * )
50
     */
51
    private string $errorMessage = '';
52
53
    /**
54
     * @OA\Property(
55
     *     property="error_code",
56
     *     format="integer",
57
     *     nullable=true,
58
     *     example=null
59
     * )
60
     */
61
    private ?int $errorCode = null;
62
63
    /**
64
     * @OA\Property(
65
     *      property="data",
66
     *      type="object",
67
     *      nullable=true,
68
     * )
69
     */
70
    private ?array $data = null;
71
72
    public function getStatus(): string
73
    {
74
        return $this->status;
75
    }
76
77
    public function setStatus(string $status): self
78
    {
79
        $this->status = $status;
80
81
        return $this;
82
    }
83
84
    public function getErrorMessage(): string
85
    {
86
        return $this->errorMessage;
87
    }
88
89
    public function setErrorMessage(string $errorMessage): self
90
    {
91
        $this->errorMessage = $errorMessage;
92
93
        return $this;
94
    }
95
96
    public function getErrorCode(): ?int
97
    {
98
        return $this->errorCode;
99
    }
100
101
    public function setErrorCode(int $errorCode): self
102
    {
103
        $this->errorCode = $errorCode;
104
105
        return $this;
106
    }
107
108
    public function getData(): ?array
109
    {
110
        return $this->data;
111
    }
112
113
    public function setData(?array $data): self
114
    {
115
        $this->data = $data;
116
117
        return $this;
118
    }
119
120
    public function toArray(): array
121
    {
122
        return [
123
            'status'        => $this->getStatus(),
124
            'error_message' => $this->getErrorMessage(),
125
            'error_code'    => $this->getErrorCode(),
126
            'data'          => $this->getData(),
127
        ];
128
    }
129
}
130