CanRenderErrors::renderErrors()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 4.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
ccs 3
cts 6
cp 0.5
rs 10
cc 3
nc 2
nop 0
crap 4.125
1
<?php
2
3
namespace Nip\Form\Renderer\Elements\Traits;
4
5
/**
6
 * Trait HasErrorsTrait
7
 * @package Nip\Form\Renderer\Elements\Traits
8
 */
9
trait CanRenderErrors
10
{
11
    /**
12
     * @return string
13
     */
14
    public function renderErrors()
15 8
    {
16
        $return = '';
17 8
        if ($this->getElement()->isError() && $this->getElement()->getForm()->getOption('renderElementErrors') !== false) {
0 ignored issues
show
Bug introduced by
It seems like getElement() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        if ($this->/** @scrutinizer ignore-call */ getElement()->isError() && $this->getElement()->getForm()->getOption('renderElementErrors') !== false) {
Loading history...
18 8
            $errors = $this->getElement()->getErrors();
19
            $errors_string = implode('<br />', $errors);
20
            $return .= '<div class="help-inline invalid-feedback">' . $errors_string . '</div>';
21
        }
22
23
        return $return;
24 8
    }
25
}
26