Passed
Push — master ( 87b8d3...fbe0eb )
by Vasyl
02:57
created

LocaleScopes::scopeByLocale()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Fomvasss\UrlAliases\Traits;
4
5
trait LocaleScopes
6
{
7
8
    /**
9
     * @param $query
10
     * @param null $locale
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $locale is correct as it would always require null to be passed?
Loading history...
11
     * @return mixed
12
     */
13
    public function scopeByLocale($query, $locale = null)
14
    {
15
        $locale = $locale ?: \UrlAliasLocalization::getCurrentLocale();
0 ignored issues
show
Bug introduced by
The type UrlAliasLocalization 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...
introduced by
$locale is of type null, thus it always evaluated to false.
Loading history...
16
17
        return $query->whereLocale($locale);
18
    }
19
20
21
    /**
22
     * @param $query
23
     * @param null $locales
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $locales is correct as it would always require null to be passed?
Loading history...
24
     * @return mixed
25
     */
26
    public function scopeByLocales($query, $locales = null)
27
    {
28
        $locales = $locales ?: session('app_locales');
0 ignored issues
show
Bug introduced by
The function session 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

28
        $locales = $locales ?: /** @scrutinizer ignore-call */ session('app_locales');
Loading history...
introduced by
$locales is of type null, thus it always evaluated to false.
Loading history...
29
30
        if ($locales) {
31
            return $query->whereIn('locale', is_array($locales) ? $locales : [$locales]);
32
        }
33
    }
34
}