REQUEST::hasBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Annotation;
10
11
use Tebru\AnnotationReader\AbstractAnnotation;
12
13
/**
14
 * Defines an HTTP request type to a REST path relative to base URL.
15
 *
16
 * This is a generic annotation that lets you define an http request
17
 * outside the standard GET, POST, etc
18
 *
19
 * @author Nate Brunette <[email protected]>
20
 *
21
 * @Annotation
22
 * @Target({"CLASS", "METHOD"})
23
 */
24
class REQUEST extends AbstractAnnotation implements HttpRequest
25
{
26
    /**
27
     * The request method
28
     *
29
     * @var string
30
     */
31
    private $type;
32
33
    /**
34
     * If the request contains a body
35
     *
36
     * @var bool
37
     */
38
    private $body;
39
40
    /**
41
     * Initialize annotation data
42
     */
43 1
    protected function init(): void
44
    {
45 1
        $this->assertKey('type');
46
47 1
        $this->type = $this->data['type'];
48 1
        $this->body = $this->data['body'] ?? false;
49 1
    }
50
51
52
    /**
53
     * Returns the type of the annotation (get, post, put, etc)
54
     *
55
     * @return string
56
     */
57 1
    public function getType(): string
58
    {
59 1
        return $this->type;
60
    }
61
62
    /**
63
     * Returns true if the request type contains a body
64
     *
65
     * @return bool
66
     */
67 1
    public function hasBody(): bool
68
    {
69 1
        return $this->body;
70
    }
71
}
72