Passed
Push — master ( 821d9b...d02e66 )
by Arthur
06:56 queued 03:25
created

RelationsDoc   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 212
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 114
dl 0
loc 212
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setDeleteRelation() 0 35 1
A setRelations() 0 41 1
A setRelated() 0 41 1
A setCreateRelation() 0 35 1
A setUpdateRelation() 0 35 1
1
<?php
2
3
namespace SoliDry\Documentation;
4
5
use SoliDry\Types\DefaultInterface;
6
use SoliDry\Types\DocumentationInterface;
7
use SoliDry\Types\PhpInterface;
8
9
trait RelationsDoc
10
{
11
    /**
12
     *  Sets OAS documentation for a related method
13
     */
14
    private function setRelated(): void
15
    {
16
        $this->openComment();
0 ignored issues
show
Bug introduced by
It seems like openComment() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        $this->/** @scrutinizer ignore-call */ 
17
               openComment();
Loading history...
17
18
        $this->setStarredComment(DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES);
0 ignored issues
show
Bug introduced by
It seems like setStarredComment() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $this->/** @scrutinizer ignore-call */ 
19
               setStarredComment(DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES);
Loading history...
19
20
        $this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH
21
            . strtolower($this->generator->objectName) . PhpInterface::SLASH . '{id}/{related}",', 1, 1);
22
23
        $this->setStarredComment('summary="Get ' . $this->generator->objectName . ' related objects",', 1, 1);
24
25
        $this->setStarredComment('tags={"' . $this->generator->objectName . DefaultInterface::CONTROLLER_POSTFIX
26
            . '"},', 1, 1);
27
28
        $this->setParameter([
0 ignored issues
show
Bug introduced by
It seems like setParameter() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $this->/** @scrutinizer ignore-call */ 
29
               setParameter([
Loading history...
29
            'in'       => '"query"',
30
            'name'     => '"data"',
31
            'required' => 'false',
32
        ]);
33
34
        $this->setParameter([
35
            'in'       => '"path"',
36
            'name'     => '"id"',
37
            'required' => 'true',
38
        ]);
39
40
        $this->setParameter([
41
            'in'       => '"path"',
42
            'name'     => '"related"',
43
            'required' => 'true',
44
        ]);
45
46
        $this->setResponse([
0 ignored issues
show
Bug introduced by
It seems like setResponse() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        $this->/** @scrutinizer ignore-call */ 
47
               setResponse([
Loading history...
47
            'response'    => '200',
48
            'description' => '""',
49
        ]);
50
51
        $this->setStarredComment(PhpInterface::CLOSE_PARENTHESES);
52
53
        $this->closeComment();
0 ignored issues
show
Bug introduced by
It seems like closeComment() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        $this->/** @scrutinizer ignore-call */ 
54
               closeComment();
Loading history...
54
        $this->setNewLines();
0 ignored issues
show
Bug introduced by
It seems like setNewLines() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        $this->/** @scrutinizer ignore-call */ 
55
               setNewLines();
Loading history...
55
    }
56
57
    /**
58
     *  Sets OAS documentation for getting relations method
59
     */
60
    private function setRelations(): void
61
    {
62
        $this->openComment();
63
64
        $this->setStarredComment(DocumentationInterface::OA_GET . PhpInterface::OPEN_PARENTHESES);
65
66
        $this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH
67
            . strtolower($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1);
68
69
        $this->setStarredComment('summary="Get ' . $this->generator->objectName . ' relations objects",', 1, 1);
70
71
        $this->setStarredComment('tags={"' . $this->generator->objectName . DefaultInterface::CONTROLLER_POSTFIX
72
            . '"},', 1, 1);
73
74
        $this->setParameter([
75
            'in'       => '"query"',
76
            'name'     => '"data"',
77
            'required' => 'false',
78
        ]);
79
80
        $this->setParameter([
81
            'in'       => '"path"',
82
            'name'     => '"id"',
83
            'required' => 'true',
84
        ]);
85
86
        $this->setParameter([
87
            'in'       => '"path"',
88
            'name'     => '"relations"',
89
            'required' => 'true',
90
        ]);
91
92
        $this->setResponse([
93
            'response'    => '200',
94
            'description' => '""',
95
        ]);
96
97
        $this->setStarredComment(PhpInterface::CLOSE_PARENTHESES);
98
99
        $this->closeComment();
100
        $this->setNewLines();
101
    }
102
103
    /**
104
     *  Sets OAS documentation for creating relation method
105
     */
106
    private function setCreateRelation(): void
107
    {
108
        $this->openComment();
109
110
        $this->setStarredComment(DocumentationInterface::OA_POST . PhpInterface::OPEN_PARENTHESES);
111
112
        $this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH
113
            . strtolower($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1);
114
115
        $this->setStarredComment('summary="Create ' . $this->generator->objectName . ' relation object",', 1, 1);
116
117
        $this->setStarredComment('tags={"' . $this->generator->objectName . DefaultInterface::CONTROLLER_POSTFIX
118
            . '"},', 1, 1);
119
120
        $this->setParameter([
121
            'in'       => '"path"',
122
            'name'     => '"id"',
123
            'required' => 'true',
124
        ]);
125
126
        $this->setParameter([
127
            'in'       => '"path"',
128
            'name'     => '"relations"',
129
            'required' => 'true',
130
        ]);
131
132
        $this->setResponse([
133
            'response'    => '200',
134
            'description' => '""',
135
        ]);
136
137
        $this->setStarredComment(PhpInterface::CLOSE_PARENTHESES);
138
139
        $this->closeComment();
140
        $this->setNewLines();
141
    }
142
143
    /**
144
     *  Sets OAS documentation for updating relation method
145
     */
146
    private function setUpdateRelation(): void
147
    {
148
        $this->openComment();
149
150
        $this->setStarredComment(DocumentationInterface::OA_PATCH . PhpInterface::OPEN_PARENTHESES);
151
152
        $this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH
153
            . strtolower($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1);
154
155
        $this->setStarredComment('summary="Update ' . $this->generator->objectName . ' relation object",', 1, 1);
156
157
        $this->setStarredComment('tags={"' . $this->generator->objectName . DefaultInterface::CONTROLLER_POSTFIX
158
            . '"},', 1, 1);
159
160
        $this->setParameter([
161
            'in'       => '"path"',
162
            'name'     => '"id"',
163
            'required' => 'true',
164
        ]);
165
166
        $this->setParameter([
167
            'in'       => '"path"',
168
            'name'     => '"relations"',
169
            'required' => 'true',
170
        ]);
171
172
        $this->setResponse([
173
            'response'    => '200',
174
            'description' => '""',
175
        ]);
176
177
        $this->setStarredComment(PhpInterface::CLOSE_PARENTHESES);
178
179
        $this->closeComment();
180
        $this->setNewLines();
181
    }
182
183
    /**
184
     *  Sets OAS documentation for deleting relation method
185
     */
186
    private function setDeleteRelation(): void
187
    {
188
        $this->openComment();
189
190
        $this->setStarredComment(DocumentationInterface::OA_DELETE . PhpInterface::OPEN_PARENTHESES);
191
192
        $this->setStarredComment('path="' . PhpInterface::SLASH . $this->generator->version . PhpInterface::SLASH
193
            . strtolower($this->generator->objectName) . PhpInterface::SLASH . '{id}/relationships/{relations}",', 1, 1);
194
195
        $this->setStarredComment('summary="Delete ' . $this->generator->objectName . ' relation object",', 1, 1);
196
197
        $this->setStarredComment('tags={"' . $this->generator->objectName . DefaultInterface::CONTROLLER_POSTFIX
198
            . '"},', 1, 1);
199
200
        $this->setParameter([
201
            'in'       => '"path"',
202
            'name'     => '"id"',
203
            'required' => 'true',
204
        ]);
205
206
        $this->setParameter([
207
            'in'       => '"path"',
208
            'name'     => '"relations"',
209
            'required' => 'true',
210
        ]);
211
212
        $this->setResponse([
213
            'response'    => '200',
214
            'description' => '""',
215
        ]);
216
217
        $this->setStarredComment(PhpInterface::CLOSE_PARENTHESES);
218
219
        $this->closeComment();
220
        $this->setNewLines();
221
    }
222
}