Lines
100.00%
5 / 5
Functions and Methods
100.00%
3 / 3
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| CustomMedalTier | 100.00% | 5 / 5 | 100.00% | 3 / 3 | 4 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| image | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| label | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Medal; | |
| 6 | ||
| 7 | /** | |
| 8 | * An agent's custom medal at one tier ("" for a medal without tiers). | |
| 9 | */ | |
| 10 | final readonly class CustomMedalTier | |
| 11 | { | |
| 12 | public function __construct( | |
| 13 | public CustomMedal $medal, | |
| 14 | public string $tier, | |
| 15 | ) { | |
| 16 | } | |
| 17 | ||
| 18 | public function image(): string | |
| 19 | { | |
| 20 | return $this->medal->image($this->tier); | |
| 21 | } | |
| 22 | ||
| 23 | public function label(): string | |
| 24 | { | |
| 25 | if ('' === $this->tier) { | |
| 26 | return $this->medal->title; | |
| 27 | } | |
| 28 | ||
| 29 | // "black" is onyx, as everywhere else | |
| 30 | return \sprintf('%s (%s)', $this->medal->title, Medal::TIERS[$this->tier] ?? \ucfirst($this->tier)); | |
| 31 | } | |
| 32 | } |