Completed
Push — master ( 5b04ab...a06757 )
by ARCANEDEV
07:06
created

Blog   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 6.9%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 2
cbo 3
dl 0
loc 97
ccs 2
cts 29
cp 0.069
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A publishMigrations() 0 4 1
A routes() 0 11 1
A getSupportedLocalesKeys() 0 8 2
A __clone() 0 4 1
A instance() 0 8 2
A isTranslatable() 0 4 1
A isMediaManagerInstalled() 0 4 1
1
<?php namespace Arcanesoft\Blog;
2
3
use Arcanesoft\Blog\Http\Routes\Front as Routes;
4
use Illuminate\Support\Facades\Route;
5
6
/**
7
 * Class     Blog
8
 *
9
 * @package  Arcanesoft\Blog
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class Blog
13
{
14
    /* -----------------------------------------------------------------
15
     |  Properties
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Indicates if migrations will be run.
21
     *
22
     * @var bool
23
     */
24
    public static $runsMigrations = true;
25
26
    protected static $instance = null;
27
28
    /* -----------------------------------------------------------------
29
     |  Main Methods
30
     | -----------------------------------------------------------------
31
     */
32
33
    /**
34
     * Get the blog instance.
35
     *
36
     * @return Blog
37
     */
38
    public static function instance()
39
    {
40
        if (is_null(static::$instance)) {
41
            static::$instance = new static;
42
        }
43
44
        return static::$instance;
45
    }
46
47
    /**
48
     * Publish the migrations.
49
     */
50
    public static function publishMigrations()
51
    {
52
        static::$runsMigrations = false;
53
    }
54
55
    /**
56
     * Register the public blog routes.
57
     */
58
    public static function routes()
59
    {
60
        Route::name('public::blog.')
61
            ->prefix('blog')
62
            ->namespace('\\Arcanesoft\\Blog\\Http\\Controllers\\Front')
63
            ->group(function () {
64
                Routes\PostsRoutes::register();
65
                Routes\CategoriesRoutes::register();
66
                Routes\TagsRoutes::register();
67
            });
68
    }
69
70
    /**
71
     * Check if the blog is translatable.
72
     *
73
     * @return bool
74
     */
75
    public function isTranslatable()
76
    {
77
        return config('arcanesoft.blog.translatable.enabled', false);
78
    }
79
80
    /**
81
     * Get the supported locales.
82
     *
83
     * @return array
84
     */
85
    public function getSupportedLocalesKeys()
86
    {
87
        $default = [config('app.locale')];
88
89
        return $this->isTranslatable()
90
            ? array_unique(config('localization.supported-locales', $default))
91
            : $default;
92
    }
93
94
    /**
95
     * Check if the media manager is installed.
96
     *
97
     * @return bool
98
     */
99 3
    public function isMediaManagerInstalled()
100
    {
101 3
        return array_key_exists('Arcanesoft\Media\MediaServiceProvider', app()->getLoadedProviders());
102
    }
103
104
    protected function __clone()
105
    {
106
        // YOU ... SHALL NOT ... CLOOOOOONE!
107
    }
108
}
109