value = $value; } /** * Set the previous value for the metric. * * @param int|float|numeric-string|null $previous * @param string $label * @return $this */ public function previous($previous, $label = null) { $this->previous = $previous; $this->previousLabel = $label; return $this; } /** * Indicate that the metric represents a dollar value. * * @param string $symbol * @return $this */ public function dollars($symbol = '$') { return $this->currency($symbol); } /** * Indicate that the metric represents a currency value. * * @param string $symbol * @return $this */ public function currency($symbol = '$') { return $this->prefix($symbol); } /** * Set the metric value prefix. * * @param string $prefix * @return $this */ public function prefix($prefix) { $this->prefix = $prefix; return $this; } /** * Set the metric value suffix. * * @param string $suffix * @return $this */ public function suffix($suffix) { $this->suffix = $suffix; return $this; } /** * Don't apply suffix inflections. * * @return $this */ public function withoutSuffixInflection() { $this->suffixInflection = false; return $this; } /** * Set the metric value formatting. * * @param array|string $format * @return $this * * @phpstan-param TNumbroFormat|string $format */ public function format($format) { $this->format = $format; return $this; } /** * Set the metric value tooltip formatting. * * @param string $format * @return $this */ public function tooltipFormat($format) { $this->tooltipFormat = $format; return $this; } /** * Sets the zeroResult value. * * @param bool $zeroResult * @return $this */ public function allowZeroResult($zeroResult = true) { $this->zeroResult = $zeroResult; return $this; } /** * Allow the metric value to be copyable to the clipboard inside Nova. * * @return $this */ public function copyable() { $this->copyable = true; return $this; } /** * Prepare the metric result for JSON serialization. * * @return array */ public function jsonSerialize(): array { return [ 'copyable' => $this->copyable, 'format' => $this->format, 'prefix' => $this->prefix, 'previous' => $this->resolveTransformedValue($this->previous), 'previousLabel' => $this->previousLabel, 'suffix' => $this->suffix, 'suffixInflection' => $this->suffixInflection, 'tooltipFormat' => $this->tooltipFormat, 'value' => $this->resolveTransformedValue($this->value), 'zeroResult' => $this->zeroResult, ]; } }