TranslationValuesRule::passes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SaasReady\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
0 ignored issues
show
Bug introduced by
The type Illuminate\Contracts\Validation\Rule was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SaasReady\Constants\LanguageCode;
7
8
class TranslationValuesRule implements Rule
9
{
10
    public function passes($attribute, $value): bool
11
    {
12
        if (!is_array($value)) {
13
            return false;
14
        }
15
16
        return collect($value)
0 ignored issues
show
Bug introduced by
The function collect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

16
        return /** @scrutinizer ignore-call */ collect($value)
Loading history...
17
            ->filter(fn ($value, $key) => !LanguageCode::tryFrom($key))
18
            ->isEmpty();
19
    }
20
21
    public function message(): string
22
    {
23
        return 'Translation values had invalid language code';
24
    }
25
}
26