# solid-performance/1.5.0/src/Performance/Timer/Duration.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.5.0. 42 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.5.0/code/src/Performance/Timer/Duration.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.5.0/raw/src/Performance/Timer/Duration.php
- Modified: 2025-02-13T01:04:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.5.0/code/src/Performance/Timer/Duration.php#L10-L20`.

```php
<?php
/**
 * Formats a duration in a human-readable format.
 *
 * @package SolidWP\Performance
 */

declare( strict_types=1 );

namespace SolidWP\Performance\Timer;

/**
 * Formats a duration in a human-readable format.
 *
 * @package SolidWP\Performance
 */
final class Duration {

	/**
	 * The duration in seconds.
	 *
	 * @var float
	 */
	private float $seconds;

	/**
	 * @param  float $seconds The duration in seconds.
	 */
	public function __construct( float $seconds ) {
		$this->seconds = $seconds;
	}

	/**
	 * Format the duration in human-readable form.
	 *
	 * @return string In the format of: 2 hours, 14 minutes, 9 seconds
	 */
	public function format(): string {
		return human_readable_duration( gmdate( 'H:i:s', (int) $this->seconds ) );
	}
}

```
