1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* There are all requests with responses. |
4
|
|
|
* |
5
|
|
|
* @package App |
6
|
|
|
* |
7
|
|
|
* @copyright YetiForce Sp. z o.o. |
8
|
|
|
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
9
|
|
|
* @author Tomasz Kur <[email protected]> |
10
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace App\Log; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Api class. |
17
|
|
|
*/ |
18
|
|
|
class Api extends AbstractBase |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** {@inheritdoc} */ |
21
|
|
|
protected static $fileName = 'cache' . \DIRECTORY_SEPARATOR . 'logs' . \DIRECTORY_SEPARATOR . 'api.log'; |
22
|
|
|
|
23
|
|
|
/** {@inheritdoc} */ |
24
|
|
|
public static function display($value, string $type): string |
25
|
|
|
{ |
26
|
|
|
$content = str_repeat('-', 50) . ' ' . $value['request']['date'] . ' ' . str_repeat('-', 50) . PHP_EOL; |
27
|
|
|
$content .= 'Trace: ' . PHP_EOL . print_r(\App\Debug::getBacktrace(), true) . PHP_EOL; |
28
|
|
|
$content .= "Method: [{$value['request']['requestType']}] {$value['request']['method']}\n"; |
29
|
|
|
$content .= 'Headers: ' . print_r($value['request']['headers'], true) . PHP_EOL; |
30
|
|
|
if (!empty($value['request']['rawBody'])) { |
31
|
|
|
$content .= "RawBody: \n" . print_r($value['request']['rawBody'], true) . PHP_EOL; |
32
|
|
|
} |
33
|
|
View Code Duplication |
if (!empty($value['request']['body'])) { |
|
|
|
|
34
|
|
|
$content .= 'Body: ' . print_r($value['request']['body'], true) . PHP_EOL . PHP_EOL; |
35
|
|
|
} |
36
|
|
|
$content .= "Status: {$value['response']['status']}\n"; |
37
|
|
|
$content .= "Reason phrase: {$value['response']['reasonPhrase']}\n"; |
38
|
|
|
$content .= "Time: {$value['response']['time']} sec.\n"; |
39
|
|
|
if (!empty($value['response']['error'])) { |
40
|
|
|
$content .= "Error: {$value['response']['error']}\n"; |
41
|
|
|
} |
42
|
|
|
$headers = []; |
43
|
|
|
foreach ($value['response']['headers'] as $key => $header) { |
44
|
|
|
$headers[$key] = implode("\n", $header); |
45
|
|
|
} |
46
|
|
|
$content .= 'Headers: ' . print_r($headers, true) . PHP_EOL; |
47
|
|
View Code Duplication |
if (!empty($value['response']['rawBody'])) { |
|
|
|
|
48
|
|
|
$content .= "RawBody: \n" . print_r($value['response']['rawBody'], true) . PHP_EOL; |
49
|
|
|
} |
50
|
|
View Code Duplication |
if (!empty($value['response']['body'])) { |
|
|
|
|
51
|
|
|
$content .= 'Body: ' . print_r($value['response']['body'], true) . PHP_EOL; |
52
|
|
|
} |
53
|
|
|
return $content; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.