Failed Conditions
Push — master ( 6560de...8483ce )
by Florent
05:17
created

Message   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 0
dl 0
loc 85
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A low() 0 4 1
A medium() 0 4 1
A high() 0 4 1
A getMessage() 0 4 1
A getSeverity() 0 4 1
A jsonSerialize() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Component\KeyManagement\KeyAnalyzer;
15
16
/**
17
 * Class Message.
18
 */
19
final class Message implements \JsonSerializable
20
{
21
    /**
22
     * @var string
23
     */
24
    private $message;
25
26
    /**
27
     * @var string
28
     */
29
    private $severity;
30
31
    public const SEVERITY_LOW = 'low';
32
    public const SEVERITY_MEDIUM = 'medium';
33
    public const SEVERITY_HIGH = 'high';
34
35
    /**
36
     * Message constructor.
37
     *
38
     * @param string $message
39
     * @param string $severity
40
     */
41
    private function __construct(string $message, string $severity)
42
    {
43
        $this->message = $message;
44
        $this->severity = $severity;
45
    }
46
47
    /**
48
     * @param string $message
49
     *
50
     * @return Message
51
     */
52
    public static function low(string $message): Message
53
    {
54
        return new self($message, self::SEVERITY_LOW);
55
    }
56
57
    /**
58
     * @param string $message
59
     *
60
     * @return Message
61
     */
62
    public static function medium(string $message): Message
63
    {
64
        return new self($message, self::SEVERITY_MEDIUM);
65
    }
66
67
    /**
68
     * @param string $message
69
     *
70
     * @return Message
71
     */
72
    public static function high(string $message): Message
73
    {
74
        return new self($message, self::SEVERITY_HIGH);
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getMessage(): string
81
    {
82
        return $this->message;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getSeverity(): string
89
    {
90
        return $this->severity;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function jsonSerialize()
97
    {
98
        return [
99
            'message' => $this->message,
100
            'severity' => $this->severity,
101
        ];
102
    }
103
}
104