Passed
Push — master ( 7c0b30...83b5cd )
by Sebastian
02:33
created

getCommentString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Commands_Command_Comment} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Commands
7
 * @see Mailcode_Commands_Command_Comment
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Mailcode command: Add a comment.
16
 *
17
 * @package Mailcode
18
 * @subpackage Commands
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
class Mailcode_Commands_Command_Comment extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone
22
{
23
   /**
24
    * @var string
25
    */
26
    private $commentString = '';
27
    
28
    protected function init() : void
29
    {
30
        $this->commentString = trim(trim($this->paramsString), '"');
31
        $this->paramsString = '"Dummy"'; // so the command does not complain that it is empty
32
    }
33
    
34
    public function getName() : string
35
    {
36
        return 'comment';
37
    }
38
    
39
    public function getLabel() : string
40
    {
41
        return t('Add a comment');
42
    }
43
    
44
    public function supportsType(): bool
45
    {
46
        return false;
47
    }
48
    
49
    public function getDefaultType() : string
50
    {
51
        return '';
52
    }
53
54
    public function requiresParameters(): bool
55
    {
56
        return true;
57
    }
58
    
59
    public function supportsLogicKeywords() : bool
60
    {
61
        return false;
62
    }
63
64
    protected function getValidations() : array
65
    {
66
        return array(
67
            'comment'
68
        );
69
    }
70
    
71
    public function generatesContent() : bool
72
    {
73
        return false;
74
    }
75
    
76
    public function getCommentString() : string
77
    {
78
        return $this->commentString;
79
    }
80
    
81
    protected function validateSyntax_comment() : void
82
    {
83
        if(empty($this->commentString))
84
        {
85
            $this->validationResult->makeError(
86
                t('The comment text ist empty.'),
87
                Mailcode_Commands_CommonConstants::VALIDATION_COMMENT_MISSING
88
            );
89
        }
90
    }
91
}
92