SchemalessServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 22 3
A register() 0 2 1
1
<?php
2
3
namespace PrismX\Schemaless;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Support\Str;
7
use PrismX\Schemaless\Commands\MakeDocument;
8
use PrismX\Schemaless\Commands\MakeDocumentResource;
9
10
class SchemalessServiceProvider extends ServiceProvider
11
{
12
    public function boot()
13
    {
14
        if ($this->app->runningInConsole()) {
15
            $this->commands([
16
                MakeDocument::class,
17
                MakeDocumentResource::class,
18
            ]);
19
        }
20
21
        if (! class_exists('CreateDocumentsTable')) {
22
            $this->publishes([
23
                __DIR__.'/../database/migrations/create__documents_table.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create__documents_table.php'),
24
            ], 'migrations');
25
        }
26
27
        Str::macro('normalize', function ($str) {
28
            /** @var \Illuminate\Support\Str $this */
29
            $str = preg_replace('/(?<!^)[A-Z]/', ' $0', $str);
30
            $str = Str::slug($str);
31
            $str = str_replace('-', ' ', $str);
32
33
            return Str::title($str);
34
        });
35
    }
36
37
    public function register()
38
    {
39
    }
40
}
41