ApiResponseData::setData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
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\Attributes as OA;
0 ignored issues
show
Bug introduced by
The type OpenApi\Attributes 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
#[OA\Schema(
10
    schema: 'Response'
11
)]
12
#[OA\Schema(
13
    schema: 'BadResponse',
14
    allOf: [
15
        new OA\Schema(ref: '#/components/schemas/Response'),
16
        new OA\Schema(properties: [
17
            new OA\Property(property: 'status', example: 'failed'),
18
            new OA\Property(property: 'error_message', example: 'Error description message'),
19
            new OA\Property(property: 'error_code', example: '400', nullable: true),
20
            new OA\Property(property: 'data', example: null),
21
        ]),
22
    ]
23
)]
24
final class ApiResponseData
25
{
26
    #[OA\Property(
27
        property: 'status',
28
        format: 'string',
29
        enum: ['success', 'failed'],
30
        example: 'success'
31
    )]
32
    private string $status = '';
33
34
    #[OA\Property(
35
        property: 'error_message',
36
        format: 'string',
37
        example: ''
38
    )]
39
    private string $errorMessage = '';
40
41
    #[OA\Property(
42
        property: 'error_code',
43
        format: 'integer',
44
        example: null,
45
        nullable: true
46
    )]
47
    private ?int $errorCode = null;
48
49
    #[OA\Property(
50
        property: 'data',
51
        type: 'object',
52
        nullable: true
53
    )]
54
    private ?array $data = null;
55
56
    public function getStatus(): string
57
    {
58
        return $this->status;
59
    }
60
61
    public function setStatus(string $status): self
62
    {
63
        $this->status = $status;
64
65
        return $this;
66
    }
67
68
    public function getErrorMessage(): string
69
    {
70
        return $this->errorMessage;
71
    }
72
73
    public function setErrorMessage(string $errorMessage): self
74
    {
75
        $this->errorMessage = $errorMessage;
76
77
        return $this;
78
    }
79
80
    public function getErrorCode(): ?int
81
    {
82
        return $this->errorCode;
83
    }
84
85
    public function setErrorCode(int $errorCode): self
86
    {
87
        $this->errorCode = $errorCode;
88
89
        return $this;
90
    }
91
92
    public function getData(): ?array
93
    {
94
        return $this->data;
95
    }
96
97
    public function setData(?array $data): self
98
    {
99
        $this->data = $data;
100
101
        return $this;
102
    }
103
104
    public function toArray(): array
105
    {
106
        return [
107
            'status' => $this->getStatus(),
108
            'error_message' => $this->getErrorMessage(),
109
            'error_code' => $this->getErrorCode(),
110
            'data' => $this->getData(),
111
        ];
112
    }
113
}
114