Completed
Branch dev-master (f3e1e5)
by Derek Stephen
20:25
created

AbstractErrorRender   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A shouldRender() 0 4 3
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 04/12/2016
5
 * Time: 23:50
6
 */
7
8
namespace Del\Form\Renderer\Error;
9
10
use DOMDocument;
11
use Del\Form\Field\FieldInterface;
12
13
abstract class AbstractErrorRender implements ErrorRendererInterface
14
{
15
    /** @var DOMDocument */
16
    protected $dom;
17
18
    /**
19
     * AbstractErrorRender constructor.
20
     * @param DOMDocument $dom
21
     */
22 24
    public function __construct(DOMDocument $dom)
23
    {
24 24
        $this->dom = $dom;
25 24
    }
26
27
    /**
28
     * @param FieldInterface $field
29
     * @return bool
30
     */
31 5
    public function shouldRender(FieldInterface $field)
32
    {
33 5
        return !$field->isValid() && ($field->isRequired() || !empty($field->getValue()));
34
    }
35
}