FamilyForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 18
c 1
b 0
f 0
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 8 1
A edit() 0 10 1
1
<?php
2
3
namespace App\Forms\Builders;
4
5
use App\Family;
6
use App\Person;
7
use App\Type;
8
use LaravelEnso\Forms\Services\Form;
9
10
class FamilyForm
11
{
12
    protected const TemplatePath = __DIR__.'/../Templates/families.json';
13
14
    protected Form $form;
15
16
    public function __construct()
17
    {
18
        $this->form = new Form(static::TemplatePath);
19
    }
20
21
    public function create()
22
    {
23
        return $this->form
24
    ->options('husband_id', Person::all())
25
    ->options('wife_id', Person::all())
26
    ->options('type_id', Type::all())
27
    ->options('child_id', Person::all())
28
    ->create();
29
    }
30
31
    public function edit(Family $family)
32
    {
33
        return $this->form
34
        ->options('husband_id', Person::all())
35
        ->options('wife_id', Person::all())
36
        ->options('type_id', Type::all())
37
        ->append('family_id', $family->id)
38
        ->value('child_id', $family->children)
39
        ->options('child_id', Person::all())
40
        ->edit($family);
41
    }
42
}
43