$dataCollector =
new SerializerDataCollector();
$caller =
['name' => 'Foo.php', 'file' => 'src/Foo.php', 'line' => 123
];
$dataCollector->
collectEncode('traceIdOne', 'data', 'format',
['foo' => 'bar'
], 20.0,
$caller);
$dataCollector->
collectDecode('traceIdTwo', 'data', 'format',
['foo' => 'bar'
], 20.0,
$caller);
$dataCollector->
collectEncoding('traceIdOne', JsonEncoder::
class, 1.0
);
$dataCollector->
collectEncoding('traceIdOne', JsonEncoder::
class, 2.0
);
$dataCollector->
collectEncoding('traceIdOne', CsvEncoder::
class, 5.0
);
$dataCollector->
collectEncoding('traceIdOne', CsvEncoder::
class, 10.0
);
$dataCollector->
collectDecoding('traceIdTwo', JsonEncoder::
class, 1.0
);
$dataCollector->
collectDecoding('traceIdTwo', JsonEncoder::
class, 2.0
);
$dataCollector->
collectDecoding('traceIdTwo', CsvEncoder::
class, 5.0
);
$dataCollector->
collectDecoding('traceIdTwo', CsvEncoder::
class, 10.0
);
$dataCollector->
lateCollect();
$collectedData =
$dataCollector->
getData();
$this->
assertSame(10.0,
$collectedData['encode'
][0
]['encoder'
]['time'
]);
$this->
assertSame('CsvEncoder',
$collectedData['encode'
][0
]['encoder'
]['class'
]);
$this->
assertArrayHasKey('file',
$collectedData['encode'
][0
]['encoder'
]);
$this->
assertArrayHasKey('line',
$collectedData['encode'
][0
]['encoder'
]);