Completed
Pull Request — master (#3407)
by Antoine
05:48
created

Schema::setDefinitions()   A

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
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ApiPlatform\Core\OpenApi;
15
16
use ApiPlatform\Core\JsonSchema\Schema as JsonSchema;
17
18
class Schema
19
{
20
    private $nullable;
21
    private $discriminator;
22
    private $readOnly;
23
    private $writeOnly;
24
    private $xml;
25
    private $externalDocs;
26
    private $example;
27
    private $deprecated;
28
29
    public function __construct(?bool $nullable = false, $discriminator = null, bool $readOnly = false, bool $writeOnly = false, string $xml = null, $externalDocs = null, $example = null, bool $deprecated = false)
30
    {
31
        $this->nullable = $nullable;
32
        $this->discriminator = $discriminator;
33
        $this->readOnly = $readOnly;
34
        $this->writeOnly = $writeOnly;
35
        $this->xml = $xml;
36
        $this->externalDocs = $externalDocs;
37
        $this->example = $example;
38
        $this->deprecated = $deprecated;
39
        $this->schema = new JsonSchema();
0 ignored issues
show
Bug Best Practice introduced by
The property schema does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
    }
41
42
    public function setDefinitions(array $definitions)
43
    {
44
        $this->schema->setDefinitions(new \ArrayObject($definitions));
45
    }
46
47
    public function getDefinitions(): \ArrayObject
48
    {
49
        return new \ArrayObject(array_merge((array) $this->schema->getDefinitions(), (array) $this));
50
    }
51
}
52