Completed
Pull Request — master (#628)
by Amrouche
03:23
created

Documentation   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 46
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A getMimeTypes() 0 4 1
A getVersion() 0 4 1
A getDescription() 0 4 1
A getTitle() 0 4 1
A getResourceNameCollection() 0 4 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(ResourceNameCollection $resourceNameCollection, string $title = '', string $description = '', string $version = '', array $formats = [])
30
    {
31
        $this->resourceNameCollection = $resourceNameCollection;
32
        $this->title = $title;
33
        $this->description = $description;
34
        $this->version = $version;
35
        foreach ($formats as $format => $mimeTypes) {
36
            foreach ($mimeTypes as $mimeType) {
37
                $this->mimeTypes[] = $mimeType;
38
            }
39
        }
40
    }
41
42
    public function getMimeTypes(): array
43
    {
44
        return $this->mimeTypes;
45
    }
46
47
    public function getVersion() : string
48
    {
49
        return $this->version;
50
    }
51
52
    public function getDescription(): string
53
    {
54
        return $this->description;
55
    }
56
57
    public function getTitle(): string
58
    {
59
        return $this->title;
60
    }
61
62
    public function getResourceNameCollection(): ResourceNameCollection
63
    {
64
        return $this->resourceNameCollection;
65
    }
66
}
67