* @return string
*/
public function toString() {
- $truncFunc = function ( $value ) {
- $value = (string)$value;
- if ( mb_strlen( $value ) > 1024 ) {
- $value = "string(" . mb_strlen( $value ) . ")";
- }
- return $value;
- };
-
$paramString = '';
if ( $this->params ) {
foreach ( $this->params as $key => $value ) {
if ( is_array( $value ) ) {
$filteredValue = [];
foreach ( $value as $k => $v ) {
- if ( is_scalar( $v ) ) {
- $filteredValue[$k] = $truncFunc( $v );
+ $json = FormatJson::encode( $v );
+ if ( $json === false || mb_strlen( $json ) > 512 ) {
+ $filteredValue[$k] = gettype( $v ) . '(...)';
} else {
- $filteredValue = null;
- break;
+ $filteredValue[$k] = $v;
}
}
- if ( $filteredValue && count( $filteredValue ) < 10 ) {
+ if ( count( $filteredValue ) <= 10 ) {
$value = FormatJson::encode( $filteredValue );
} else {
$value = "array(" . count( $value ) . ")";
$value = "object(" . get_class( $value ) . ")";
}
- $paramString .= "$key={$truncFunc( $value )}";
+ $flatValue = (string)$value;
+ if ( mb_strlen( $value ) > 1024 ) {
+ $flatValue = "string(" . mb_strlen( $value ) . ")";
+ }
+
+ $paramString .= "$key={$flatValue}";
}
}
$this->getMockJob( [ $mockToStringObj ] ),
'someCommand 0={STRING_OBJ_VAL}'
],
+ [
+ $this->getMockJob( [
+ "pages" => [
+ "932737" => [
+ 0,
+ "Robert_James_Waller"
+ ]
+ ],
+ "rootJobSignature" => "45868e99bba89064e4483743ebb9b682ef95c1a7",
+ "rootJobTimestamp" => "20160309110158",
+ "masterPos" => [
+ "file" => "db1023-bin.001288",
+ "pos" => "308257743",
+ "asOfTime" => 1457521464.3814
+ ],
+ "triggeredRecursive" => true
+ ] ),
+ 'someCommand pages={"932737":[0,"Robert_James_Waller"]} ' .
+ 'rootJobSignature=45868e99bba89064e4483743ebb9b682ef95c1a7 ' .
+ 'rootJobTimestamp=20160309110158 masterPos=' .
+ '{"file":"db1023-bin.001288","pos":"308257743","asOfTime":1457521464.3814} ' .
+ 'triggeredRecursive=1'
+ ],
];
}