DummyResponseContext   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A assertIsValid() 0 3 1
A getArray() 0 3 1
A getObject() 0 3 1
A getRaw() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace GinoPane\NanoRest\Response;
4
5
/**
6
 * Class DummyResponseContext
7
 *
8
 * Dummy result context, can be used as default
9
 */
10
class DummyResponseContext extends ResponseContextAbstract
11
{
12
    /**
13
     * Get raw result data
14
     *
15
     * @param array $options
16
     *
17
     * @return string|null
18
     */
19
    public function getRaw(array $options = array()): ?string
20
    {
21
        return $this->content;
22
    }
23
24
    /**
25
     * Get result data as array
26
     *
27
     * @param array $options
28
     *
29
     * @return array
30
     */
31
    public function getArray(array $options = array()): array
32
    {
33
        return (array)$this->content;
34
    }
35
36
    /**
37
     * Get result data as object
38
     *
39
     * @param array $options
40
     *
41
     * @return object
42
     */
43
    public function getObject(array $options = array())
44
    {
45
        return (object)$this->content;
46
    }
47
48
    /**
49
     * String representation of response for debug purposes
50
     *
51
     * @return string
52
     */
53
    public function __toString(): string
54
    {
55
        return print_r($this->content, true);
56
    }
57
58
    /**
59
     * Makes sure that $content is valid for this AbstractResponseContext instance
60
     *
61
     * @param string $content
62
     *
63
     * @return bool
64
     */
65
    protected function assertIsValid(string $content): bool
66
    {
67
        return true;
68
    }
69
}
70