Operation::getReference()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Joli\Jane\OpenApi\Operation;
4
5
use Joli\Jane\OpenApi\Model\Operation as OpenApiOperation;
6
7
class Operation
8
{
9
    const DELETE  = 'DELETE';
10
    const GET     = 'GET';
11
    const POST    = 'POST';
12
    const PUT     = 'PUT';
13
    const PATCH   = 'PATCH';
14
    const OPTIONS = 'OPTIONS';
15
    const HEAD    = 'HEAD';
16
17
    /**
18
     * @var \Joli\Jane\OpenApi\Model\Operation
19
     */
20
    private $operation;
21
22
    /**
23
     * @var string
24
     */
25
    private $path;
26
27
    /**
28
     * @var string
29
     */
30
    private $method;
31
32
    /**
33
     * @var string
34
     */
35
    private $reference;
36
37 12
    public function __construct(OpenApiOperation $operation, $path, $method, $reference, $basePath = "", $host = 'localhost')
38
    {
39 12
        $this->operation = $operation;
40 12
        $this->path      = preg_replace('#^/+#', '/', $basePath . $path);
41 12
        $this->method    = $method;
42 12
        $this->host      = $host;
0 ignored issues
show
Bug introduced by
The property host does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
43 12
        $this->reference = $reference;
44 12
    }
45
46
    /**
47
     * @return string
48
     */
49 12
    public function getMethod()
50
    {
51 12
        return $this->method;
52
    }
53
54
    /**
55
     * @return \Joli\Jane\OpenApi\Model\Operation
56
     */
57 12
    public function getOperation()
58
    {
59 12
        return $this->operation;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 12
    public function getPath()
66
    {
67 12
        return $this->path;
68
    }
69
70
    /**
71
     * @return string
72
     */
73 12
    public function getHost()
74
    {
75 12
        return $this->host;
76
    }
77
78
    /**
79
     * @return string
80
     */
81 12
    public function getReference()
82
    {
83 12
        return $this->reference;
84
    }
85
}
86