Completed
Push — master ( a3f58b...5e1e7e )
by Luca
02:14
created

Debugger   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 64
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A getInstance() 0 8 2
A recordRequest() 0 4 1
A getRequests() 0 4 1
A recordCurlInfo() 0 4 1
A getCurlInfo() 0 4 1
1
<?php
2
/**
3
 * OpenFireRestAPI is based entirely on official documentation of the REST API
4
 * Plugin and you can extend it by following the directives of the documentation
5
 *
6
 * For the full copyright and license information, please read the LICENSE
7
 * file that was distributed with this source code. For the full list of
8
 * contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
9
 *
10
 * @author Luca Agnello <[email protected]>
11
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
12
 */
13
14
namespace Gnello\OpenFireRestAPI\Utils;
15
16
use Gnello\OpenFireRestAPI\Wrappers\AbstractRegistryWrapper;
17
18
/**
19
 * Class Debugger
20
 * @package Gnello\OpenFireRestAPI\Utils
21
 */
22
class Debugger extends AbstractRegistryWrapper
23
{
24
    const REQUESTS  = 0;
25
    const CURL_INFO = 1;
26
27
    /**
28
     * @var Debugger
29
     */
30
    private static $instance;
31
32
    /**
33
     * Settings constructor.
34
     */
35
    private function __construct() {}
36
37
    /**
38
     * @return Debugger
39
     */
40
    public static function getInstance()
41
    {
42
        if (is_null(self::$instance)) {
43
            self::$instance = new Debugger();
44
        }
45
46
        return self::$instance;
47
    }
48
49
    /**
50
     * @param $url
51
     * @param $headers
52
     * @param $method
53
     * @param $postData
54
     * @param $response
55
     * @param $server_output
56
     */
57
    public function recordRequest($url, $headers, $method, $postData, $response, $server_output)
58
    {
59
        $this->set(array(self::REQUESTS), compact('url', 'headers', 'method', 'postData', 'response', 'server_output'));
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getRequests()
66
    {
67
        return $this->get(self::REQUESTS);
68
    }
69
70
    /**
71
     * @param $curlInfo
72
     */
73
    public function recordCurlInfo($curlInfo)
74
    {
75
        $this->set(self::CURL_INFO, $curlInfo);
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function getCurlInfo()
82
    {
83
        return $this->get(self::CURL_INFO);
84
    }
85
}
86