Mailcode_Traits_Commands_Validation_EmptyParams   A
last analyzed

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
 * @see Mailcode_Interfaces_Commands_Validation_EmptyParams
27
 */
28
trait Mailcode_Traits_Commands_Validation_EmptyParams
29
{
30
    abstract public function requiresParameters() : bool;
31
32
    protected function validateSyntax_params_empty() : void
33
    {
34
        if(!$this->requiresParameters())
35
        {
36
            return;
37
        }
38
39
        if(empty($this->paramsString))
40
        {
41
            $this->validationResult->makeError(
42
                t('Parameters have to be specified.'),
43
                Mailcode_Commands_Command::VALIDATION_MISSING_PARAMETERS
44
            );
45
            return;
46
        }
47
    }
48
}
49