Completed
Push — master ( 9e4d7b...c3f58e )
by Gabriel
03:57 queued 11s
created

CanRenderErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
dl 0
loc 16
ccs 4
cts 7
cp 0.5714
rs 10
c 1
b 0
f 0

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
    /**
13
     * @return string
14
     */
15 8
    public function renderErrors()
16
    {
17 8
        $return = '';
18 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

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