| Total Complexity | 8 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 44.44% |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 5 | class TrustVote |
||
| 6 | { |
||
| 7 | public const VOTE_ABSTAIN = 'abstain'; |
||
| 8 | |||
| 9 | public const VOTE_TRUSTED = 'trusted'; |
||
| 10 | |||
| 11 | public const VOTE_UNTRUSTED = 'untrusted'; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $type; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string|null |
||
| 20 | */ |
||
| 21 | private $reason; |
||
| 22 | |||
| 23 | 1 | private function __construct(string $type, ?string $reason = null) |
|
| 24 | { |
||
| 25 | 1 | $this->type = $type; |
|
| 26 | 1 | $this->reason = $reason; |
|
| 27 | 1 | } |
|
| 28 | |||
| 29 | public function isAbstain(): bool |
||
| 30 | { |
||
| 31 | return $this->type === self::VOTE_ABSTAIN; |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function isTrusted(): bool |
|
| 35 | { |
||
| 36 | 1 | return $this->type === self::VOTE_TRUSTED; |
|
| 37 | } |
||
| 38 | |||
| 39 | public function isUntrusted(): bool |
||
| 40 | { |
||
| 41 | return $this->type === self::VOTE_UNTRUSTED; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function getReason(): ?string |
||
| 45 | { |
||
| 46 | return $this->reason; |
||
| 47 | } |
||
| 48 | |||
| 49 | 1 | public static function trusted(): self |
|
| 50 | { |
||
| 51 | 1 | return new TrustVote(self::VOTE_TRUSTED); |
|
| 52 | } |
||
| 53 | |||
| 54 | public static function abstain(): self |
||
| 55 | { |
||
| 56 | return new TrustVote(self::VOTE_ABSTAIN); |
||
| 57 | } |
||
| 58 | |||
| 59 | public static function untrusted(?string $reason = null): self |
||
| 62 | } |
||
| 63 | } |
||
| 64 |