Completed
Pull Request — master (#628)
by Amrouche
06:57 queued 03:03
created

Documentation   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 52
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getMimeTypes() 0 4 1
A getVersion() 0 4 1
A getDescription() 0 4 1
A getTitle() 0 4 1
A __construct() 0 11 3
A create() 0 6 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(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