/** * @param string $messageName * @param array $parameters Parameters with value === `null` will be filtered out. */ private function write($messageName, array $parameters) { /** @noinspection AdditionOperationOnArraysInspection */ $parameters = ['timestamp' => Util::formatTimestamp(), 'flowId' => $this->flowId] + $parameters; // Filter out optional parameters. $parameters = array_filter($parameters, function ($value) { return $value !== null; }); $this->writer->write(Util::format($messageName, $parameters)); }
public function testFormatTimestampNow() { $now = new DateTime(); $result = Util::formatTimestamp(); self::assertEquals($now, new DateTime($result), '', 1.0); }