Completed
Push — master ( ca59d5...30f23d )
by Derek Stephen
01:52
created

AbstractErrorRender::shouldRender()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 3
eloc 2
nc 3
nop 1
crap 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 23
    public function __construct(DOMDocument $dom)
23
    {
24 23
        $this->dom = $dom;
25 23
    }
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
}