Completed
Pull Request — master (#472)
by Théo
03:07
created

AttributesBag::getResourceClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Http;
13
14
/**
15
 * @author Théo FIDRY <[email protected]>
16
 */
17
final class AttributesBag
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $collectionOperationName;
23
24
    /**
25
     * @var string|null
26
     */
27
    private $itemOperationName;
28
29
    /**
30
     * @var string
31
     */
32
    private $format;
33
34
    /**
35
     * @var string
36
     */
37
    private $resourceClass;
38
39
    /**
40
     * @param string      $resourceClass           Resource FQCN
41
     * @param string|null $collectionOperationName Example: 'get', 'post', etc.
42
     * @param string|null $itemOperationName       Example: 'get', 'post', etc.
43
     * @param string      $format                  Example: 'jsonld'
44
     */
45
    public function __construct(
46
        string $resourceClass,
47
        string $collectionOperationName = null,
48
        string $itemOperationName = null,
49
        string $format
50
    ) {
51
        $this->resourceClass = $resourceClass;
52
        $this->collectionOperationName = $collectionOperationName;
53
        $this->itemOperationName = $itemOperationName;
54
        $this->format = $format;
55
    }
56
57
    /**
58
     * @return string|null Is null if is an item operation
59
     *
60
     * @example
61
     *  'get', 'post', etc.
62
     */
63
    public function getCollectionOperationName()
64
    {
65
        return $this->collectionOperationName;
66
    }
67
68
    /**
69
     * @return string|null Is null if is a collection operation
70
     *
71
     * @example
72
     *  'get', 'post', etc.
73
     */
74
    public function getItemOperationName()
75
    {
76
        return $this->itemOperationName;
77
    }
78
79
    /**
80
     * @return string
81
     *
82
     * @example
83
     *  'jsonld'
84
     */
85
    public function getFormat()
86
    {
87
        return $this->format;
88
    }
89
90
    /**
91
     * @return string Resource FQCN
92
     */
93
    public function getResourceClass()
94
    {
95
        return $this->resourceClass;
96
    }
97
}
98