Skip to content

Commit 3ca06c8

Browse files
committed
Merge pull request #5 from dimitrytarasov/master
Pick out TypeConverter as a separate class
2 parents 067d53d + 7dbda33 commit 3ca06c8

2 files changed

Lines changed: 32 additions & 22 deletions

File tree

src/Stackify/Log/Entities/Api/WebRequestDetail.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Stackify\Log\Entities\Api;
44

5+
use Stackify\Utils\TypeConverter;
6+
57
class WebRequestDetail
68
{
79

@@ -125,7 +127,7 @@ public static function getRequestMap($data, $maskValues = false)
125127
foreach ($data as $key => $value) {
126128
$result[$key] = $maskValues
127129
? self::HIDDEN_VALUE
128-
: self::stringify($value);
130+
: TypeConverter::stringify($value);
129131
}
130132
}
131133
return empty($result) ? null : $result;
@@ -193,25 +195,4 @@ private function getHeaders()
193195
return empty($headers) ? null : $headers;
194196
}
195197

196-
/**
197-
* Converts any PHP type to string
198-
* @param mixed $value
199-
* @return string
200-
*/
201-
private static function stringify($value)
202-
{
203-
$string = '';
204-
if (is_scalar($value)) {
205-
// integer, float, string, boolean
206-
$string = (string)$value;
207-
} elseif (is_resource($value)) {
208-
// resource
209-
$string = '[resource]';
210-
} else {
211-
// array, object, null, callable
212-
$string = json_encode($value);
213-
}
214-
return $string;
215-
}
216-
217198
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Stackify\Utils;
4+
5+
class TypeConverter
6+
{
7+
8+
/**
9+
* Converts any PHP type to string
10+
* @param mixed $value
11+
* @return string
12+
*/
13+
public static function stringify($value)
14+
{
15+
$string = '';
16+
if (is_scalar($value)) {
17+
// integer, float, string, boolean
18+
$string = (string)$value;
19+
} elseif (is_resource($value)) {
20+
// resource
21+
$string = '[resource]';
22+
} else {
23+
// array, object, null, callable
24+
$string = json_encode($value);
25+
}
26+
return $string;
27+
}
28+
29+
}

0 commit comments

Comments
 (0)