Test Setup Failed
Push — master ( e4f8c2...f9e497 )
by Sebastian
03:34
created

Mailcode_Traits_Commands_Validation_EmptyParams   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 18
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSyntax_params_empty() 0 14 3
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Traits_Commands_Validation_EmptyParams} trait.
4
 *
5
 * @package Mailcode
6
 * @subpackage Validation
7
 * @see Mailcode_Traits_Commands_Validation_EmptyParams
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use AppUtils\OperationResult;
15
16
/**
17
 * Command validation drop-in: verifies if the command parameters
18
 * are empty, and if they are required, adds an error accordingly.
19
 *
20
 * @package Mailcode
21
 * @subpackage Validation
22
 * @author Sebastian Mordziol <[email protected]>
23
 *
24
 * @property OperationResult $validationResult
25
 */
26
trait Mailcode_Traits_Commands_Validation_EmptyParams
27
{
28
    abstract public function requiresParameters() : bool;
29
30
    protected function validateSyntax_params_empty() : void
31
    {
32
        if(!$this->requiresParameters())
33
        {
34
            return;
35
        }
36
37
        if(empty($this->paramsString))
38
        {
39
            $this->validationResult->makeError(
40
                t('Parameters have to be specified.'),
41
                Mailcode_Commands_Command::VALIDATION_MISSING_PARAMETERS
42
            );
43
            return;
44
        }
45
    }
46
}
47