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

AttributesBag   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 81
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getCollectionOperationName() 0 4 1
A getItemOperationName() 0 4 1
A getFormat() 0 4 1
A getResourceClass() 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\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