FieldsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultTypes() 0 10 2
A register() 0 5 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
7
/**
8
 * Class FieldsServiceProvider
9
 * @package Hechoenlaravel\JarvisFoundation\Providers
10
 */
11
class FieldsServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * The system Field types
15
     * @var array
16
     */
17
    public $defaultTypes = [
18
        'text' => \Hechoenlaravel\JarvisFoundation\Field\Text\TextFieldType::class,
19
        'email' => \Hechoenlaravel\JarvisFoundation\Field\Email\EmailFieldType::class,
20
        'textarea' => \Hechoenlaravel\JarvisFoundation\Field\TextArea\TextAreaFieldType::class,
21
        'date' => \Hechoenlaravel\JarvisFoundation\Field\Date\DateFieldType::class,
22
        'select' => \Hechoenlaravel\JarvisFoundation\Field\Select\SelectFieldType::class
23
    ];
24
25
    /**
26
     * Register the service provider.
27
     *
28
     * @return void
29
     */
30
    public function register()
31
    {
32
        $this->app->singleton('field.types', 'Hechoenlaravel\JarvisFoundation\Field\FieldTypes');
33
        $this->setDefaultTypes();
34
    }
35
36
    /**
37
     * Set the default Field Types
38
     */
39
    public function setDefaultTypes()
40
    {
41
        $types = $this->app->make('field.types');
42
        foreach ($this->defaultTypes as $alias => $fieldType) {
43
            $types->addFieldType([
44
                'type' => $alias,
45
                'class' => $fieldType
46
            ]);
47
        }
48
    }
49
}
50