Lines 100.00% 3 / 3
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AdminAction 100.00% 3 / 3 100.00% 1 / 1 3 100.00% 1 / 1
 listAllowedMethods 100.00% 3 / 3 100.00% 1 / 1 3
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Http\Admin;
6
7enum AdminAction: string
8{
9    case ListApps = 'list';
10    case ShowApp = 'show';
11    case PauseApp = 'pause';
12    case ResumeApp = 'resume';
13    case ResetApp = 'reset';
14    case RestartWorker = 'restart';
15    case ShowMetrics = 'metrics';
16
17    /** @return non-empty-list<non-empty-string> */
18    public function listAllowedMethods(): array
19    {
20        return match ($this) {
21            self::ListApps, self::ShowApp, self::ShowMetrics => ['GET', 'HEAD'],
22            self::PauseApp, self::ResumeApp, self::ResetApp, self::RestartWorker => ['POST'],
23        };
24    }
25}