ModelProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A modelsProvider() 0 13 1
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
use Illuminate\Support\Collection;
6
7
trait ModelProvider
8
{
9
    /**
10
     * Retrieve an array of models to be used as test params.
11
     *
12
     * @param  string  $modelClass
13
     * @param  int|null  $limit
14
     * @return array
15
     */
16
    protected function modelsProvider(string $modelClass, int $limit = null): array
17
    {
18
        $this->refreshApplication();
0 ignored issues
show
Bug introduced by
It seems like refreshApplication() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

18
        $this->/** @scrutinizer ignore-call */ 
19
               refreshApplication();
Loading history...
19
20
        return $modelClass::query()
21
            ->get()
22
            ->when(isset($limit), function (Collection $collection) use ($limit) {
23
                return $collection->shuffle()->take($limit);
24
            })
25
            ->map(function ($model) {
26
                return [$model];
27
            })
28
            ->toArray();
29
    }
30
}
31