Lines 0.00% 0 / 22
Methods 0.00% 0 / 1
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 messageTemplate 0.00% 0 / 22 0.00% 0 / 1 506
9enum ControlError: string implements ExceptionReason
10{
11    case SocketInUse = 'socket_in_use';
12    case SocketUnremovable = 'socket_unremovable';
13    case SocketDirectoryNotCreatable = 'socket_directory_not_creatable';
14    case SocketPathNotASocket = 'socket_path_not_a_socket';
15    case FrameNotJson = 'frame_not_json';
16    case FrameNotAnObject = 'frame_not_an_object';
17    case FrameUnencodable = 'frame_unencodable';
18    case FrameClassUnknown = 'frame_class_unknown';
19    case FrameUndecodable = 'frame_undecodable';
20    case ConfigUnavailable = 'config_unavailable';
21    case ControlDisabled = 'control_disabled';
22    case TokenMissing = 'token_missing';
23    case ConnectionRejected = 'connection_rejected';
24    case UnexpectedGreeting = 'unexpected_greeting';
25    case ProtocolMismatch = 'protocol_mismatch';
26    case BrokerHungUp = 'broker_hung_up';
27    case UnexpectedFrame = 'unexpected_frame';
28    case RequestTimedOut = 'request_timed_out';
29    case RequestUnexpected = 'request_unexpected';
30    case RequestFailed = 'request_failed';
31    case RequestUnanswerable = 'request_unanswerable';
32
33    public function messageTemplate(): string
34    {
35        return match ($this) {
36            self::SocketInUse => 'Another daemon is already listening on {address}. Stop it or change control.listen.',
37            self::SocketUnremovable => 'Could not remove the stale control socket {path}.',
38            self::SocketDirectoryNotCreatable => 'Could not create control socket directory {directory}.',
39            self::SocketPathNotASocket => 'The control socket path {path} exists and is not a socket.',
40            self::FrameNotJson => 'Frame is not JSON: {cause}',
41            self::FrameNotAnObject => 'Frame is {actualType}; expected a JSON object.',
42            self::FrameUnencodable => 'Could not encode {frameClass}: {cause}',
43            self::FrameClassUnknown => 'Unknown frame {frameClass}.',
44            self::FrameUndecodable => 'Could not decode the "{frameType}" control frame: {cause}',
45            self::ConfigUnavailable => 'Could not read control.listen and control.token (pass --address and --token): {cause}',
46            self::ControlDisabled => 'The configuration sets control.listen to off; pass --address.',
47            self::TokenMissing => 'No control token; set STEWART_CONTROL__TOKEN or pass --token.',
48            self::ConnectionRejected => 'The broker refused the connection: {reason}',
49            self::UnexpectedGreeting => 'The broker sent {frameClass} instead of a welcome.',
50            self::ProtocolMismatch => 'Broker speaks control protocol {brokerProtocol}, this client {clientProtocol}.',
51            self::BrokerHungUp => 'The broker hung up before the session ended.',
52            self::UnexpectedFrame => 'The broker sent {frameClass} instead of {expectedFrameClass}.',
53            self::RequestTimedOut => 'The broker did not answer within {timeout}.',
54            self::RequestUnexpected => 'The control session expects a request, not {frameClass}.',
55            self::RequestFailed => 'The broker refused the request: {message}',
56            self::RequestUnanswerable => 'The broker could not answer the request: {cause}',
57        };
58    }
59}