Passed
Push — master ( acf3f9...98cfe3 )
by Derek Stephen
03:04
created

AbstractErrorRender   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 4
c 0
b 0
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A shouldRender() 0 3 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
use Del\Form\Traits\HasDomTrait;
13
14
abstract class AbstractErrorRender implements ErrorRendererInterface
15
{
16
    use HasDomTrait;
17
18
    /**
19
     * AbstractErrorRender constructor.
20
     * @param DOMDocument $dom
21
     */
22 66
    public function __construct(DOMDocument $dom)
23
    {
24 66
        $this->setDom($dom);
25 66
    }
26
27
    /**
28
     * @param FieldInterface $field
29
     * @return bool
30
     */
31 6
    public function shouldRender(FieldInterface $field)
32
    {
33 6
        return !$field->isValid() && ($field->isRequired() || !empty($field->getValue()));
34
    }
35
}