Message::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * This file is part of CaptainHook.
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console\IO;
13
14
/**
15
 * Class Message
16
 *
17
 * @package CaptainHook
18
 * @author  Sebastian Feldmann <[email protected]>
19
 * @link    https://github.com/captainhook-git/captainhook
20
 * @since   Class available since Release 5.19.0
21
 */
22
class Message
23
{
24
    /**
25
     * Message, either a string or list of string for multiple lines
26
     *
27
     * @var string|array<string>
28
     */
29
    private string|array $message;
30
31
    /**
32
     * Should message be ended with a new line character
33
     *
34
     * @var bool
35
     */
36
    private bool $newLine;
37
38
    /**
39
     * Current application verbosity
40
     *
41
     * @var int
42
     */
43
    private int $verbosity;
44
45
    /**
46
     * Constructor
47
     *
48
     * @param string|array<string> $message
49
     * @param bool                 $newLine
50
     * @param int                  $verbosity
51
     */
52 24
    public function __construct(string|array $message, bool $newLine, int $verbosity)
53
    {
54 24
        $this->message   = $message;
55 24
        $this->newLine   = $newLine;
56 24
        $this->verbosity = $verbosity;
57
    }
58
59
    /**
60
     * Returns the message to print
61
     *
62
     * @return string|array<string>
63
     */
64 9
    public function message(): string|array
65
    {
66 9
        return $this->message;
67
    }
68
69
    /**
70
     * If true message should end with a new line
71
     *
72
     * @return bool
73
     */
74 9
    public function newLine(): bool
75
    {
76 9
        return $this->newLine;
77
    }
78
79
    /**
80
     * Minimum verbosity this message should be displayed at
81
     *
82
     * @return int
83
     */
84 23
    public function verbosity(): int
85
    {
86 23
        return $this->verbosity;
87
    }
88
}
89