Completed
Pull Request — master (#628)
by Amrouche
04:04 queued 56s
created

Documentation::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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
namespace ApiPlatform\Core\Documentation;
13
14
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
15
16
/**
17
 * Generates the API documentation.
18
 *
19
 * @author Amrouche Hamza <[email protected]>
20
 */
21
final class Documentation
22
{
23
    private $resourceNameCollection;
24
    private $title;
25
    private $description;
26
    private $version;
27
    private $mimeTypes = [];
28
29
    public function __construct(string $title = '', string $description = '', string $version = '', array $formats = [])
30
    {
31
        $this->title = $title;
32
        $this->description = $description;
33
        $this->version = $version;
34
        foreach ($formats as $format => $mimeTypes) {
35
            foreach ($mimeTypes as $mimeType) {
36
                $this->mimeTypes[] = $mimeType;
37
            }
38
        }
39
    }
40
41
    public function create($resourceNameCollection): Documentation
42
    {
43
        $this->resourceNameCollection = $resourceNameCollection;
44
45
        return $this;
46
    }
47
48
    public function getMimeTypes(): array
49
    {
50
        return $this->mimeTypes;
51
    }
52
53
    public function getVersion() : string
54
    {
55
        return $this->version;
56
    }
57
58
    public function getDescription(): string
59
    {
60
        return $this->description;
61
    }
62
63
    public function getTitle(): string
64
    {
65
        return $this->title;
66
    }
67
68
    public function getResourceNameCollection(): ResourceNameCollection
69
    {
70
        return $this->resourceNameCollection;
71
    }
72
}
73