Completed
Push — master ( 936da0...f7c12a )
by Pascal
14:46 queued 13:50
created

Component   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 10 1
A isWired() 0 4 1
A isNotWired() 0 4 1
1
<?php
2
3
namespace ProtoneMedia\LaravelFormComponents\Components;
4
5
use Illuminate\Support\Str;
6
use Illuminate\View\Component as BaseComponent;
7
use ProtoneMedia\LaravelFormComponents\FormDataBinder;
8
9
abstract class Component extends BaseComponent
10
{
11
    /**
12
     * {@inheritDoc}
13
     */
14
    public function render()
15
    {
16
        $alias = Str::kebab(class_basename($this));
17
18
        $config = config("form-components.components.{$alias}");
19
20
        $framework = config("form-components.framework");
21
22
        return str_replace('{framework}', $framework, $config['view']);
23
    }
24
25
    /**
26
     * Returns a boolean wether the form is wired to a Livewire component.
27
     *
28
     * @return boolean
29
     */
30
    public function isWired(): bool
31
    {
32
        return app(FormDataBinder::class)->isWired();
33
    }
34
35
    /**
36
     * The inversion of 'isWired()'.
37
     *
38
     * @return boolean
39
     */
40
    public function isNotWired(): bool
41
    {
42
        return !$this->isWired();
43
    }
44
}
45