Completed
Push — master ( fcd315...e54b6a )
by John
02:20
created

OpenApiDescription::__construct()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 8.8571
c 1
b 0
f 0
cc 5
eloc 7
nc 12
nop 1
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\ApiDescriptions package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\ApiDescriptions\Description\OpenApi;
10
11
use KleijnWeb\ApiDescriptions\Description\Description;
12
use KleijnWeb\ApiDescriptions\Document\Document;
13
14
/**
15
 * @author John Kleijn <[email protected]>
16
 */
17
class OpenApiDescription extends Description
18
{
19
    /**
20
     * Description constructor.
21
     *
22
     * @param Document $document
23
     */
24
    public function __construct(Document $document)
25
    {
26
        $this->document = $document;
27
        $this->host     = isset($document->host) ? $document->host : null;
28
        $this->schemes  = isset($document->schemes) ? $document->schemes : [];
29
30
        if (isset($this->document->paths)) {
31
            foreach ($this->document->paths as $path => $pathItem) {
32
                $this->paths[$path] = new OpenApiPath($path, $pathItem);
33
            }
34
        }
35
    }
36
}
37