HasFetchScope   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeFetch() 0 6 1
A scopeFetchAll() 0 6 1
1
<?php
2
3
namespace PrismX\Schemaless\Traits;
4
5
trait HasFetchScope
6
{
7
    public function scopeFetch($query, $locale = null)
8
    {
9
        return $query
10
            ->where('collection', $this->collection)
11
            ->where('locale', $locale ?? app()->getLocale())
0 ignored issues
show
introduced by
The method getLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

11
            ->where('locale', $locale ?? app()->/** @scrutinizer ignore-call */ getLocale())
Loading history...
12
            ->firstOrFail();
13
    }
14
15
    public function scopeFetchAll($query, $locale = null)
16
    {
17
        return $query
18
            ->where('collection', $this->collection)
19
            ->where('locale', $locale ?? app()->getLocale())
20
            ->get();
21
    }
22
}
23