seconds = $seconds; $this->nanos = $nanos; } /** * Get the duration * * Example: * ``` * $res = $duration->get(); * ``` * * @return array */ public function get() { return ['seconds' => $this->seconds, 'nanos' => $this->nanos]; } /** * Format the value as a string. * * Example: * ``` * echo $duration->formatAsString(); * ``` * * @return string */ public function formatAsString() { return json_encode($this->get()); } /** * Format the value as a string. * * @return string * @access private */ public function __toString() { return $this->formatAsString(); } }