Completed
Push — master ( bca24d...1b0d8b )
by John
03:18
created

OpenApiDefinitionValidator::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 2
nop 2
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Descriptions 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\PhpApi\Descriptions\Description\Document\Definition\Validator;
10
11
use KleijnWeb\PhpApi\Descriptions\Description\Schema\Validator\DefaultValidator;
12
use KleijnWeb\PhpApi\Descriptions\Description\Schema\Validator\SchemaValidator;
13
14
/**
15
 * @author John Kleijn <[email protected]>
16
 */
17
class OpenApiDefinitionValidator extends MetaSchemaValidator
18
{
19
    /**
20
     * SpecificationValidator constructor.
21
     *
22
     * @param SchemaValidator  $validator
23
     * @param string|\stdClass $schema
24
     */
25
    public function __construct(SchemaValidator $validator = null, $schema = null)
26
    {
27
        if (null === $schema) {
28
            $schema = json_decode(file_get_contents(__DIR__ . '/../../../../../assets/swagger-schema.json'));
29
        }
30
        parent::__construct($schema, $validator ?: new DefaultValidator());
31
    }
32
}
33