Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Health
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace AqwSocketClient\Objects\Monster;
6
7use Override;
8use Psl;
9use Stringable;
10
11final readonly class Health implements Stringable
12{
13    public function __construct(
14        public readonly int $value,
15    ) {
16        Psl\invariant($this->value >= 0, 'Health cannot be negative, got %d.', $this->value);
17    }
18
19    #[Override]
20    public function __toString(): string
21    {
22        return (string) $this->value;
23    }
24}