| Total Complexity | 8 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 8 | final class Metric |
||
| 9 | { |
||
| 10 | private Config $config; |
||
| 11 | |||
| 12 | private float $time; |
||
| 13 | |||
| 14 | private Tags $tags; |
||
| 15 | |||
| 16 | private Measurements $measurements; |
||
| 17 | |||
| 18 | public function __construct(Config $config, Tags $tags, Measurements $measurements, float $time) |
||
| 19 | { |
||
| 20 | $this->config = $config; |
||
| 21 | $this->tags = $tags; |
||
| 22 | $this->measurements = $measurements; |
||
| 23 | $this->time = $time; |
||
| 24 | } |
||
| 25 | |||
| 26 | public static function create(Config $config, Tags $tags, Measurements $measurements): self |
||
| 27 | { |
||
| 28 | return new self($config, $tags, $measurements, microtime(true)); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function __toString(): string |
||
| 32 | { |
||
| 33 | return $this->config . '%' . $this->tags . '%' . $this->measurements . '%' . $this->time; |
||
| 34 | } |
||
| 35 | |||
| 36 | public static function fromString(string $string): Metric |
||
| 37 | { |
||
| 38 | [$config, $tags, $measurements, $time] = explode('%', $string); |
||
| 39 | |||
| 40 | return new Metric(Config::fromString($config), Tags::fromString($tags), Measurements::fromString($measurements), (float) $time); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function config(): Config |
||
| 44 | { |
||
| 45 | return $this->config; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function time(): float |
||
| 49 | { |
||
| 50 | return $this->time; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function tags(): Tags |
||
| 54 | { |
||
| 55 | return $this->tags; |
||
| 56 | } |
||
| 57 | |||
| 58 | public function measurements(): Measurements |
||
| 61 | } |
||
| 62 | } |
||
| 63 |