OpenApiSpecGenerated::__construct()   A
last analyzed

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
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
namespace W2w\Laravel\Apie\Events;
3
4
use erasys\OpenApi\Spec\v3\Document;
5
6
/**
7
 * Event triggered that an OpenAPI document was created. This can be used to modify the OpenApi spec being generated.
8
 */
9
class OpenApiSpecGenerated
10
{
11
    private $openApiDoc;
12
13
    /**
14
     * @param Document $openApiDoc
15
     */
16
    public function __construct(Document $openApiDoc)
17
    {
18
        $this->openApiDoc = $openApiDoc;
19
    }
20
21
    /**
22
     * @return Document
23
     */
24
    public function getDocument(): Document
25
    {
26
        return $this->openApiDoc;
27
    }
28
29
    /**
30
     * Replace the document. It's advisable to stop event propagation by returning false afterwards in your
31
     * listener.
32
     *
33
     * @param Document $document
34
     * @return OpenApiSpecGenerated
35
     */
36
    public function overrideDocument(Document $document): self {
37
        $this->openApiDoc = $document;
38
        return $this;
39
    }
40
}
41