|
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
|
|
|
|