ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Duration.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\HTTP\Duration;
20
22
26abstract class Duration
27{
31 protected const S_TO_US = 1_000_000;
32
36 protected const MS_TO_US = 1_000;
37
38 protected ?IncrementStrategy $increment = null;
39
40 public function __construct(protected int $duration_in_ms)
41 {
42 }
43
45 {
46 $clone = clone $this;
47 $clone->increment = $increment;
48
49 return $clone;
50 }
51
52 public function increment(): self
53 {
54 if (null === $this->increment) {
55 return $this;
56 }
57
58 $clone = clone $this;
59 $clone->duration_in_ms = $clone->increment->increment($clone->duration_in_ms);
60
61 return $clone;
62 }
63
64 public function withDuration(int $duration_in_ms): self
65 {
66 $clone = clone $this;
67 $clone->duration_in_ms = $duration_in_ms;
68
69 return $clone;
70 }
71
72 public function getDuration(): int
73 {
74 return $this->duration_in_ms;
75 }
76}
const MS_TO_US
number used for converting miliseconds (ms) into microseconds (us/µ) or vise-versa.
Definition: Duration.php:36
const S_TO_US
number used for converting seconds (s) into microseconds (us/µ) or vise-versa.
Definition: Duration.php:31
__construct(protected int $duration_in_ms)
Definition: Duration.php:40
withDuration(int $duration_in_ms)
Definition: Duration.php:64
withIncrement(IncrementStrategy $increment)
Definition: Duration.php:44
IncrementStrategy $increment
Definition: Duration.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...