Passed
Push — master ( 77b992...62880d )
by Sebastian
02:14
created

Mailcode_Variables_Collection_Invalid   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFirstError() 0 3 1
A getFirst() 0 5 1
A add() 0 8 2
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Variables_Collection} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Variables
7
 * @see Mailcode_Variables_Collection
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use AppUtils\OperationResult;
15
16
/**
17
 * Handler for all variable-related tasks.
18
 *
19
 * @package Mailcode
20
 * @subpackage Variables
21
 * @author Sebastian Mordziol <[email protected]>
22
 */
23
class Mailcode_Variables_Collection_Invalid extends Mailcode_Variables_Collection
24
{
25
    public function add(Mailcode_Variables_Variable $variable) : Mailcode_Variables_Collection
26
    {
27
        if($variable->isValid())
28
        {
29
            return $this;
30
        }
31
        
32
        return parent::add($variable);
33
    }
34
    
35
    public function getFirstError() : OperationResult
36
    {
37
        return $this->getFirst()->getValidationResult();
38
    }
39
        
40
    public function getFirst() : Mailcode_Variables_Variable
41
    {
42
        reset($this->variables);
43
        
44
        return $this->variables[key($this->variables)];
45
    }
46
}
47