GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractFrontendDataProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
data() 0 1 ?
A store() 0 4 1
A key() 0 16 4
A hasData() 0 4 1
1
<?php
2
3
4
namespace HiHaHo\LaravelJsStore;
5
6
use Illuminate\Support\Str;
7
8
abstract class AbstractFrontendDataProvider
9
{
10
    /**
11
     * @var string Optional key that will be used when this provider is json encoded
12
     */
13
    protected $key;
14
15
    /**
16
     * The data that will be JSON encoded
17
     *
18
     * @return mixed
19
     */
20
    abstract public function data();
21
22
    public function store()
23
    {
24
        app()->make('js-store')->put($this->key(), $this->data());
25
    }
26
27
    protected function key()
28
    {
29
        if (isset($this->key)) {
30
            return $this->key;
31
        }
32
33
        $class = (new \ReflectionClass($this))->getShortName();
34
35
        if (Str::endsWith($class, 'FrontendDataProvider')) {
36
            $name = Str::before($class, 'FrontendDataProvider');
37
        } elseif (Str::endsWith($class, 'DataProvider')) {
38
            $name = Str::before($class, 'DataProvider');
39
        }
40
41
        return Str::snake($name ?? $class);
42
    }
43
44
    public function hasData(): bool
45
    {
46
        return true;
47
    }
48
}
49