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

AbstractErrorRender::shouldRender()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 3
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
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
}