Completed
Pull Request — master (#1)
by Raymond
03:28
created

MessageAction::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.2
cc 4
eloc 9
nc 4
nop 1
1
<?php
2
3
namespace RayRutjes\GetEventStore;
4
5
final class MessageAction
6
{
7
    /**
8
     * Adds the message to the park queue.
9
     */
10
    const PARK = 'Park';
11
12
    /**
13
     * Retry the message.
14
     */
15
    const RETRY = 'Retry';
16
17
    /**
18
     * Forget about the message.
19
     */
20
    const SKIP = 'Skip';
21
22
    /**
23
     * @var string
24
     */
25
    private $action;
26
27
    /**
28
     * @param string $action
29
     */
30
    public function __construct(string $action)
31
    {
32
        switch ($action) {
33
            case self::PARK:
34
            case self::RETRY:
35
            case self::SKIP:
36
                break;
37
            default:
38
                throw new \InvalidArgumentException(sprintf('%s is an invalid message action.', $action));
39
        }
40
        $this->action = $action;
41
    }
42
}
43