PersistManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 48
ccs 8
cts 8
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A enableMigrations() 0 5 1
A isEnabled() 0 3 1
A useRecentlyViewedModel() 0 5 1
1
<?php
2
3
namespace RecentlyViewed;
4
5
class PersistManager
6
{
7
    /**
8
     * Indicates if laravel should run migrations for package.
9
     *
10
     * @var bool
11
     */
12
    public static bool $runsMigrations = false;
13
14
    /**
15
     * UsedContactModel.
16
     *
17
     * @var string
18
     */
19
    public static string $model = \RecentlyViewed\Models\RecentViews::class;
20
21
    /**
22
     * Check is persistent storage enabled.
23
     *
24
     * @return bool
25
     */
26 10
    public static function isEnabled(): bool
27
    {
28 10
        return (bool) config('recently-viewed.persist_enabled');
29
    }
30
    /**
31
     * Configure laravel to not register current package migrations.
32
     *
33
     * @return static
34
     */
35 8
    public static function enableMigrations(): static
36
    {
37 8
        static::$runsMigrations = true;
38
39 8
        return new static;
40
    }
41
42
    /**
43
     * Specify contact model to use.
44
     *
45
     * @param  string  $modelClass
46
     * @return static
47
     */
48 1
    public static function useRecentlyViewedModel(string $modelClass): static
49
    {
50 1
        static::$model = $modelClass;
51
52 1
        return new static;
53
    }
54
}
55