CanRenderErrors   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 3
cts 6
cp 0.5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderErrors() 0 10 3
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