Completed
Push — master ( 49dc1a...1f58a4 )
by Yaro
06:59
created

Errors::name()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields\Traits;
4
5
use Illuminate\Support\ViewErrorBag;
6
7
trait Errors
8
{
9 View Code Duplication
    public function hasError(ViewErrorBag $errors, $locale = null): bool
10
    {
11
        if ($locale) {
12
            return $errors->has(sprintf('%s.%s', $this->name(), $locale));
13
        }
14
15
        if ($this->belongsToArray()) {
16
            return $errors->has($this->getDotPatternName());
17
        }
18
19
        return $errors->has($this->name());
20
    }
21
22 View Code Duplication
    public function getErrors(ViewErrorBag $errors, $locale = null): array
23
    {
24
        if ($locale) {
25
            return $errors->get(sprintf('%s.%s', $this->name(), $locale));
26
        }
27
28
        if ($this->belongsToArray()) {
29
            return $errors->get($this->getDotPatternName());
30
        }
31
32
        return $errors->get($this->name());
33
    }
34
35
    abstract public function name(string $name = null);
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
36
    abstract public function belongsToArray(): bool;
37
    abstract public function getDotPatternName(): string;
38
}
39