LocaleScopes   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeByLocales() 0 7 4
A scopeByLocale() 0 6 2
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
            ->orWhereNull('locale');
19
    }
20
21
22
    /**
23
     * @param $query
24
     * @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...
25
     * @return mixed
26
     */
27
    public function scopeByLocales($query, $locales = null)
28
    {
29
        $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

29
        $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...
30
31
        if ($locales) {
32
            return $query->whereIn('locale', is_array($locales) ? $locales : [$locales])
33
                ->orWhereNull('locale');
34
        }
35
    }
36
}