Completed
Pull Request — master (#628)
by Amrouche
04:13
created

Documentation::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 1
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
15
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
16
17
/**
18
 * Generates the API documentation.
19
 *
20
 * @author Amrouche Hamza <[email protected]>
21
 */
22
23
class Documentation
24
{
25
    private $resourceNameCollection;
26
    private $title;
27
    private $description;
28
    private $version;
29
    private $mimeTypes = [];
30
31
    public function __construct(string $title = '', string $description = '', string $version = '', array $formats = [])
32
    {
33
        $this->title = $title;
34
        $this->description = $description;
35
        $this->version = $version;
36
        foreach ($formats as $format => $mimeTypes) {
37
            foreach ($mimeTypes as $mimeType) {
38
                $this->mimeTypes[] = $mimeType;
39
            }
40
        }
41
    }
42
43
    public function create($resourceNameCollection): Documentation {
44
        $this->resourceNameCollection = $resourceNameCollection;
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
64
    public function getTitle(): string
65
    {
66
        return $this->title;
67
    }
68
69
   public function getResourceNameCollection(): ResourceNameCollection {
70
       return $this->resourceNameCollection;
71
   }
72
73
}