ScriptRepository::getScripts()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.9332
1
<?php
2
3
namespace App\Repositories;
4
5
use App\Models\Script as Model;
6
use Cache;
7
8
class ScriptRepository extends InitRepository
9
{
10
    public function __construct()
11
    {
12
        parent::__construct();
13
    }
14
15
    protected function getModelClass()
16
    {
17
        return Model::class;
18
    }
19
20
    public function getScripts()
21
    {
22
        $columns = [
23
      // 'id',
24
      // 'name',
25
      'data',
26
      'top',
27
    ];
28
29
        $result = $this->startConditions()
30
      ->active()
0 ignored issues
show
Bug introduced by
The method active() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

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

30
      ->/** @scrutinizer ignore-call */ active()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
      ->select($columns)
32
      ->toBase()
33
      ->get();
34
35
        $result = $result->groupBy('top');
36
        // dd($result);
37
        return $result;
38
    }
39
40
    public function getCacheScripts()
41
    {
42
        $cache_name = 'scripts';
43
44
        if (Cache::has($cache_name) && !Cache::get($cache_name)->isEmpty()) {
45
            $data_cache = Cache::get($cache_name);
46
        } else {
47
            $data_cache = Cache::remember($cache_name, $this->cache_time_forever, function () {
48
                return $this->getScripts();
49
            });
50
        }
51
52
        return $data_cache;
53
    }
54
}
55